Submission #370486

#TimeUsernameProblemLanguageResultExecution timeMemory
370486FystyDetecting Molecules (IOI16_molecules)C++17
46 / 100
3 ms748 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<n;i++) #define F first #define S second #define pb push_back vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; vector<pll> a; rep(i,w.size()) a.pb({w[i],i}); sort(a.begin(),a.end()); int n=w.size(),sum=0; for(int i=n-1;i>=0;i--) { sum+=a[i].F; } ll tot=0,cur=0; rep(i,n+1) { if(l>u) break; //cout<<i<<" "<<tot<<" "; while(i-1>=cur) sum-=a[cur].F,cur++; while(tot+sum>u&&cur<=n-1) sum-=a[cur].F,cur++; //cout<<cur<<" "<<sum<<"\n"; if(tot+sum>=l&&tot+sum<=u) { rep(j,i) ans.pb(a[j].S); for(int j=cur;j<n;j++) ans.pb(a[j].S); break; } if(i==n) break; tot+=a[i].F; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:5:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,n) for(int i=0;i<n;i++)
......
   14 |     rep(i,w.size()) a.pb({w[i],i});
      |         ~~~~~~~~~~             
molecules.cpp:14:5: note: in expansion of macro 'rep'
   14 |     rep(i,w.size()) a.pb({w[i],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...