Submission #773018

#TimeUsernameProblemLanguageResultExecution timeMemory
773018teokakabadzeDetecting Molecules (IOI16_molecules)C++17
69 / 100
35 ms5548 KiB
#include "molecules.h" #include<bits/stdc++.h> #define pb push_back #define f first #define s second using namespace std; int s, e, sum, i; std::vector<int> find_subset(int l, int u, std::vector<int> a) { vector<int> v; vector<pair<int, int>> w; int n = a.size(); for(i = 0; i < n; i++) w.pb({a[i], i}); sort(w.begin(), w.end()); s = e = 0, sum = w[0].f; bool f = 1; while(f) { //cout << s << ' ' << e << ' ' << sum << '\n'; if(sum >= l && sum <= u) { int ans = 0; for(i = s; i <= e; i++) v.pb(w[i].s); return v; } f = 0; while(e < n - 1 && sum < l) sum += w[++e].f, f = 1; while(s < e && sum > u) sum -= w[s++].f, f = 1; } return v; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:17: warning: unused variable 'ans' [-Wunused-variable]
   25 |             int ans = 0;
      |                 ^~~
#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...