Submission #677559

#TimeUsernameProblemLanguageResultExecution timeMemory
677559hello_there_123Detecting Molecules (IOI16_molecules)C++17
100 / 100
63 ms8728 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long vector<int> find_subset(int l,int u,vector<int> w){ vector<pair<ll,ll> >lol; for(ll i=0;i<w.size();i++){ lol.push_back(make_pair(w[i],i)); } sort(lol.begin(),lol.end()); ll n = w.size(); ll pre[n+3]; for(int i=0;i<n;i++){ if(i==0) pre[i] = lol[i].first; else pre[i] = lol[i].first+pre[i-1]; } vector<int>ans; vector<ll>cur; queue<pair<int,int> >q; for(int i=1;i<=n;i++){ ll lo = i-1; ll hi = n-1; ll heh = -1; while(lo<=hi){ ll X = (lo+hi)/2; ll bruh; if(X-i<0) bruh = 0; else bruh = pre[X-i]; if(pre[X]-bruh<=u){ heh = X; lo = X+1; } else hi = X-1; } if(heh == -1) continue; ll bruh; if(heh-i<0) bruh = 0; else bruh = pre[heh-i]; if(pre[heh]-bruh>=l){ for(ll j=heh;j>=heh-i+1;j--){ ans.push_back(lol[j].second); } return ans; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |    for(ll i=0;i<w.size();i++){
      |               ~^~~~~~~~~
#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...