3322021-10-13 07:20:25rmlanBefektetéscpp14Forditási hiba
#include<bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define ll long long
#define tc int _TC_; cin >> _TC_; while(_TC_--)
using namespace std;
bool comp(vector<int> a, vector<int> b){
    return a[2] < b[2];
}
int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int> > a(n);
    for(int i = 0; i < n;i++){
        a[i].resize(3);
        int p,v,t;
        cin >> p >> v >> t;
        a[i][0]=p;
        a[i][1]=v;
        a[i][2]=t;
    }
    sort(a.begin(), a.end(), comp);
    int b[k+1]={};
    int b2[k+1]={};
    int me=0;
    //for(int i = 1; i <= k;i++) b[i]=INT_MAX;
    for(int i = 0; i < n; i++){
        if(a[i][0]+a[i][2] <= k){
b2=b;
            for(int j = 1; j <= k-a[i][0]-a[i][2]; j++){
                if(b[j] != 0 && j+a[i][0]+a[i][2] <= k){
                    b2[j+a[i][0]+a[i][2]] = max(b[j]+a[i][1], b[j+a[i][0]+a[i][2]]);
                    me=max(me, b2[j+a[i][0]+a[i][2]]);
                }
            }
            b[a[i][0]]=max(b[a[i][0]], a[i][1]);
            me=max(me, b[a[i][0]]);
            b=b2;
        }
    }
    cout << me << endl;
}
Forditási hiba
exit status 1main.cpp: In function ‘int main()’:
main.cpp:30:4: error: invalid array assignment
   30 | b2=b;
      |    ^
main.cpp:39:15: error: invalid array assignment
   39 |             b=b2;
      |               ^~
Exited with error status 1