Submission #1314621

#TimeUsernameProblemLanguageResultExecution timeMemory
1314621eldorbek_008Detecting Molecules (IOI16_molecules)C++17
100 / 100
33 ms3740 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int low, int high, vector<int> w) { int n = w.size(); vector<pair<int, int>> p(n); for (int i = 0; i < n; i++) { p[i].first = w[i]; p[i].second = i; } sort(p.begin(), p.end()); long long s = 0; int l = 0, r = 0; while (l < n and r < n) { while (r < n and s < low) { s += p[r].first; r++; } while (l < r and s > high) { s -= p[l].first; l++; } if (low <= s and s <= high) { vector<int> i; while (l < r) { i.push_back(p[l++].second); } sort(i.begin(), i.end()); return i; } } return vector<int>(0); }

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...