Submission #844701

#TimeUsernameProblemLanguageResultExecution timeMemory
844701vjudge1Pod starim krovovima (COCI20_psk)C++17
40 / 50
1 ms348 KiB
#define li #define MP make_pair #define pb push_back #define REP(i,n) for(int (i) = 0; (i) < (n); (i)++) #include <bits/stdc++.h> using namespace std; const double EPS = 0.00001; const int INF = 1e9+500; const int N = 1e5+5; int n,m,q,k; vector<int> t; vector<array<int,2> > z; vector<array<int,2> > res; vector<int> ans; void solve() { cin>>n; t.resize(n); z.resize(n); int sum = 0; for(int i = 0; i<n; i++) { cin>>t[i]>>z[i][0]; z[i][1] = i; sum += t[i]; } sort(z.begin(),z.end()); int i; int last = 0; for(i = n-1; i>=0; i--) { sum-=z[i][0]; if(sum <= 0) { last = z[i][0] + sum; res.pb({last, z[i][1]}); break; } else { res.pb(z[i]); } } cout<<i<<"\n"; ans.resize(n,0); for(int i = 0; i < res.size(); i++) { ans[res[i][1]] = res[i][0]; } for(auto i : ans) { cout<<i<<" "; } } signed main() { int test = 1; //cin>>test; while(test--) { solve(); } }

Compilation message (stderr)

psk.cpp: In function 'void solve()':
psk.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0; i < res.size(); i++) {
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...