Submission #1127470

#TimeUsernameProblemLanguageResultExecution timeMemory
1127470heeyDetecting Molecules (IOI16_molecules)C++20
100 / 100
54 ms5188 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()); queue<pair<int,int>> ss; long long s = 0; for(int i = 0; i < n; i++){ s += sigma[i].first; ss.push(sigma[i]); if(s > u){ s -= ss.front().first; ss.pop(); } if(s >= l && s <= u){ break; } } if(s > u || s < l) return vector<int>(0); vector<int> ans; while(!ss.empty()){ ans.emplace_back(ss.front().second); ss.pop(); } 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...