Submission #1127193

#TimeUsernameProblemLanguageResultExecution timeMemory
1127193heeyDetecting Molecules (IOI16_molecules)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5+2; #include "molecules.h" vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<int,int>> sigma(n); for(int i = 0; i < n; i++){ sigma[i] = {w[i], i}; } sort(sigma.begin(), sigma.end()); vector<bool> us(n, false); int L = 0, R = n-1, sum = 0; int t = n-1; while(L < R && (sum > u || sum < l)){ us[R] = true; sum += sigma[R--].first; while(sum > u){ us[t] = false; us[L] = true; sum -= sigma[t--].first; sum += sigma[L++].first; } } int res = 0; vector<int> ans; for(int i = 0; i < n; i++){ if(us[i]) { ans.emplace_back(sigma[i].second); res += sigma[i].first; } } if(res > u || res < l) return vector<int>(0); sort(ans.begin(), ans.end()); return ans; }

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...