Submission #849738

#TimeUsernameProblemLanguageResultExecution timeMemory
849738efedmrlrPod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms600 KiB
#include <bits/stdc++.h> #define int long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int (i) = 0; (i) < (n); (i)++) 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:45:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < res.size(); i++) {
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...