Submission #853176

#TimeUsernameProblemLanguageResultExecution timeMemory
853176parsadox2Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
int[] find_subset(int l , int r , int[] t) { vector <pair<int ,int>> ar; int n = t.size(); for(int i = 0 ; i < n ; i++) ar.push_back({t[i] , i + 1}); sort(ar.begin() , ar.end()); int num = 0 , sum = 0; for(int i = n - 1 ; i > -1 ; i--) { sum += ar[i].first; num++; if(sum >= l) break; } num--; if(sum < l) { int res[0]; return res; } int sum2 = 0; for(int i = 0 ; i <= num ; i++) sum2 += ar[i].first; if(sum2 > r) { int res[0]; return res; } int res[num + 1]; int pos = 0; int las = n - 1; while(sum2 < l) { sum2 += (ar[las].first - ar[num].first); num--; res[pos] = (ar[las].second); pos++; las--; } for(int i = num ; i >= 0 ; i--) { res[pos] = (ar[i].second); pos++; } reverse(res.begin() , res.end()); return res; }

Compilation message (stderr)

molecules.cpp:1:4: error: structured binding declaration cannot have type 'int'
    1 | int[] find_subset(int l , int r , int[] t)
      |    ^~
molecules.cpp:1:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:1:4: error: empty structured binding declaration
molecules.cpp:1:7: error: expected initializer before 'find_subset'
    1 | int[] find_subset(int l , int r , int[] t)
      |       ^~~~~~~~~~~