Submission #32034

#TimeUsernameProblemLanguageResultExecution timeMemory
32034osmanorhanDetecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms5144 KiB
#include "molecules.h" #include <bits/stdc++.h> #define fi first #define se second #define all( x ) x.begin(), x.end() #define umin( x, y ) x = min( x, (y) ) #define umax( x, y ) x = max( x, (y) ) #define pb push_back using namespace std; typedef long long Lint; typedef pair<int,int> ii; const int inf = 1e9 + 137; const int maxn = 200020; Lint pre[maxn]; Lint suf[maxn]; vector<int> find_subset(int l, int u, vector<int> w) { sort( all( w ) ); vector<int> ans; for(int i=0;i<w.size();i++) { if( i == 0 ) pre[i] = w[i]; else pre[i] = w[i] + pre[i-1]; } for(int i=w.size()-1;i>=0;i--) { if( i == w.size()-1 ) suf[i] = w[i]; else suf[i] = w[i] + suf[i+1]; } for(int i=0;i<w.size();i++) if( !( u < pre[i] || suf[w.size()-i-1] < l ) ) { Lint tot = 0; for(int j=0;j<i;j++) ans.pb( j ), tot += w[j]; for(int j=i-1,last=w.size()-1;j>=0;j--,last--) { if( tot >= l ) break; tot += w[last] - w[j]; ans[j] = w[last]; } return ans; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++) {
                  ^
molecules.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if( i == w.size()-1 ) suf[i] = w[i];
               ^
molecules.cpp:34:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     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...