Submission #570768

#TimeUsernameProblemLanguageResultExecution timeMemory
570768nohaxjustsofloDetecting Molecules (IOI16_molecules)C++17
100 / 100
53 ms5684 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set; mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count()); //uniform_int_distribution<int> gen(-1e9, 1e8); ///(min, max) //int random() {return gen(mt_rand);} const int mxN = 1e6+50000; const int mod = 998244353; const int mxlogN = 34; const int mxK = 26; const int inf = 1e9; const int K = 100000; vector<int> find_subset(int l, int u, vector<int> w) { int n=w.size(); vector<pair<int,int>> ws(n); for(int i=0; i<n; i++) ws[i]={w[i], i}; sort(ws.begin(), ws.end()); ll s=0; int L=0; for(int i=0; i<n; i++) { if(s+ws[i].first>u) s-=ws[L++].first; s+=ws[i].first; if(s>=l&&s<=u) { vector<int> ans; for(int j=L; j<=i; j++) ans.push_back(ws[j].second); sort(ans.begin(), ans.end()); return ans; } } return {}; } /* int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); } 1 2 3 4 5 6 */
#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...