Submission #379874

#TimeUsernameProblemLanguageResultExecution timeMemory
379874Pichon5Detecting Molecules (IOI16_molecules)C++17
69 / 100
64 ms6116 KiB
#include "molecules.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; vector<int> find_subset(int l,int r,vi w) { fast vector<pair<ll,ll> >v; for(int i=0;i<w.size();i++){ v.pb({w[i],i}); } sort(v.begin(),v.end()); int pref[w.size()];pref[0]=v[0].F; for(int i=1;i<w.size();i++){ pref[i]=pref[i-1]+v[i].F; } vi res; for(int i=0;i<w.size();i++){ ll L=0,R=i; while(L<=R){ ll mid=(L+R)/2; ll sum=pref[i]; if(mid>0)sum-=pref[mid-1]; if(sum>=l && sum<=r){ for(int l=mid;l<=i;l++){ res.pb(v[l].S); } return res; } if(sum<l){ R=mid-1; }else{ L=mid+1; } } } return res; }

Compilation message (stderr)

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