Submission #798341

#TimeUsernameProblemLanguageResultExecution timeMemory
798341LiudasDetecting Molecules (IOI16_molecules)C++17
0 / 100
2 ms304 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int L, int R, vector<int> M){ int N = M.size(); vector<pair<int, int>> arr(N); for(int i = 0; i < N; i ++){ arr[i] = {M[i], i}; } sort(arr.begin(), arr.end()); int l = 0, r = 0, S = 0; for(r; r < N; r ++){ if(S + arr[r].first < L){ S += arr[r].first; } else{break;} } while(r < N && S < L){ S -= arr[l++].first; S += arr[r++].first; } vector<int> p; if(L <= S && S <= R){ for(int i = l; i < r; i ++){ p.push_back(arr[i].second); } } return p; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:9: warning: statement has no effect [-Wunused-value]
   12 |     for(r; r < N; r ++){
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...