Submission #1268433

#TimeUsernameProblemLanguageResultExecution timeMemory
1268433MahogDetecting Molecules (IOI16_molecules)C++20
9 / 100
0 ms328 KiB
#include <bits/stdc++.h> #include "molecules.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; const int MAX = 2e5 + 2; ll id[MAX], a[MAX], n; bool cmp(int x, int y) { return a[x] > a[y]; } vector<int> find_subset(int l, int r, vector<int> w) { n = w.size(); for (int i = 1; i <= n; i++) { id[i] = i; a[i] = w[i - 1]; } sort(id + 1, id + n + 1, cmp); ll total = 0; int temp = 0; for (int i = 1; i <= n; i++) { total += a[id[i]]; if (total >= l) { temp = i; break; } } vector<int> res; if (temp == 0) return res; total = 0; for (int i = n - temp + 1; i <= n; i++) { res.push_back(id[i] - 1); total += a[id[i]]; } for (int i = 0; i < temp; i++) { if (total >= l && total <= r) return res; total += a[i + 1] - a[res[i] + 1]; res[i] = id[i + 1]; } return {}; }

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