Submission #645920

#TimeUsernameProblemLanguageResultExecution timeMemory
645920GaLzDetecting Molecules (IOI16_molecules)C++14
100 / 100
55 ms7200 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; const ll mod=1e9+7; const ll maxn=2e5+5; const int INF=1e8; #define ok ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define fi first #define se second #define pb push_back #define ub upper_bound #define lb lower_bound #define endl '\n' ll pref[maxn]; int pos; vector<pii> isi; vi find_subset(int l, int u, vi w) { for(int i=0; i<w.size(); i++) { isi.pb({w[i], i}); } sort(isi.begin(), isi.end()); vi ans; for(auto it : isi) { pos++; pref[pos]=it.fi; pref[pos]+=pref[pos-1]; } for(int i=1; i<=pos; i++) { int lf=1, rg=i, can=0; while(lf<=rg) { int mid=(lf+rg)/2; ll cur=pref[i]-pref[mid-1]; if(cur>=l && cur<=u) { can=mid; break; } else if(cur<l) rg=mid-1; else lf=mid+1; } if(can) { for(int j=can-1; j<=i-1; j++) { ans.pb(isi[j].se); } break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int 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...