Submission #1132206

#TimeUsernameProblemLanguageResultExecution timeMemory
1132206lopkusDetecting Molecules (IOI16_molecules)C++20
100 / 100
40 ms4132 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> a) { int n = (int) a.size(); vector<pair<int, int>> v; for (int i = 0; i < n; i++) { v.push_back({a[i], i}); } sort(v.begin(), v.end()); long long sum = v[0].first; int i = 0, j = 0; while (i < n && j < n) { if (sum >= l && sum <= u) { break; } if (sum <= u && j < n - 1) { if (j + 1 == n) { break; } j++; sum += v[j].first; } else { sum -= v[i].first; i++; } } vector<int> ans; if (sum >= l && sum <= u) { for (int h = i; h <= j; h++) { ans.push_back(v[h].second); } } 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...