Submission #971001

#TimeUsernameProblemLanguageResultExecution timeMemory
971001KasymKDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w){ int n = (int)w.size(); vector<pair<int, int>> v; for(int i = 0; i < n; ++i) v.push_back({i, w[i]}); auto cmp = [&](pair<int, int> a, pair<int, int> b) -> bool { if(a.second != b.second) return a.second > b.second; return a.first > b.first; }; sort(v.begin(), v.end(), cmp); long long answer = 0; vector<int> ans; for(int i = 0, j = 0; j < n; ++j){ answer += v[j].second; while(answer > u) answer -= v[i++].second; if(answer >= l){ for(int k = i; k <= j; ++k) ans.push_back(v[k].first); return ans; } } return vector<int> {}; } int main(){ int n, l, u; scanf("%d%d%d", &n, &l, &u); vector<int> v(n); for(int &i : v) scanf("%d", &i); vector<int> ans = find_subset(l, u, v); for(int i : ans) printf("%d ", i); puts(""); return 0; }

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d%d%d", &n, &l, &u);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &i);
      |         ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/cceEandW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccMAhWEU.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status