Submission #28011

#TimeUsernameProblemLanguageResultExecution timeMemory
28011repeatingDetecting Molecules (IOI16_molecules)C++11
0 / 100
0 ms2024 KiB
#include <bits/stdc++.h> #include "molecules.h" #define F first #define S second #define P push #define pb push_back #define MEM(dp,i) memset(dp,i,sizeof(dp)) #define W while #define R return #define C continue #define SI size() #define ll long long #define ld long double #define pll pair<ll,ll> #define pii pair<int,int> #define SF(x) scanf("%I64d",&x) #define SF2(x,y) scanf("%I64d%I64d",&x,&y) #define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z) #define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o) #define all(v) v.begin(),v.end() using namespace std; const long long INF = 1e9; const int MX=1000005; vector<int> r1,r2,res; vector<int> find_subset(int l, int u, vector<int> w) { sort(all(w)); int sum=0; for(int i=w.SI-1;sum<l&&i>=0;i--){ sum+=w[i]; r1.pb(w[i]); } for(int i=0;i<w.SI-r1.SI;i++){ r2.pb(w[i]); } reverse(all(r2)); reverse(all(r1)); W(sum>u){ if(r1.empty()||r2.empty())R vector<int>(0); sum-=r1.back(); // cout<<r1.back()<<" "; r1.pop_back(); res.pb(r2.back()); sum+=r2.back(); // cout<<r2.back()<<endl; r2.pop_back(); } W(!r1.empty()){ res.pb(r1.back()); r1.pop_back(); } return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:34:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI-r1.SI;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...