Submission #32035

#TimeUsernameProblemLanguageResultExecution timeMemory
32035osmanorhanDetecting Molecules (IOI16_molecules)C++14
100 / 100
73 ms9868 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<ii> w; vector<int> find_subset(int l, int u, vector<int> ww) { for(int i=0;i<ww.size();i++) w.pb( ii( ww[i], i ) ); sort( all( w ) ); vector<int> ans; for(int i=0;i<w.size();i++) { if( i == 0 ) pre[i] = w[i].fi; else pre[i] = w[i].fi + pre[i-1]; } for(int i=w.size()-1;i>=0;i--) { if( i == w.size()-1 ) suf[i] = w[i].fi; else suf[i] = w[i].fi + suf[i+1]; } for(int i=0;i<w.size();i++) if( !( u < pre[i] || suf[w.size()-i-1] < l ) ) { //printf("asd (%lld %lld) -- (%d %d)\n",pre[i],suf[w.size()-1-i],l,u); Lint tot = 0; for(int j=0;j<=i;j++) ans.pb( w[j].se ), tot += w[j].fi; for(int j=i,last=w.size()-1;j>=0;j--,last--) { if( tot >= l ) break; tot += w[last].fi - w[j].fi; ans[j] = w[last].se; } return ans; } return ans; }

Compilation message (stderr)

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