Submission #844252

#TimeUsernameProblemLanguageResultExecution timeMemory
844252vjudge1Pod starim krovovima (COCI20_psk)C++17
0 / 50
348 ms108424 KiB
#ifdef ONLINE_JUDGE #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #define int long long #define pb push_back #define lim 300000 #define till 40001 // # of primes till 1e6 = 7e4 using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; using pii = array<int,2>; const int mod=1000000007ll; void solve(){ int n; cin>>n; int vol[n]; int tot=0; for(int i=0;i<n;i++){ int use; cin>>use; tot+=use; cin>>vol[i]; } map<int,vector<int>>all; vector<int>a(vol,vol+n); sort(a.begin(),a.end(),greater<int>()); int cur=0,grr=0; for(int i=0;i<n;i++){ if(tot-cur>a[i]){ //cerr<<a[i]<<"a\n"; all[a[i]].pb(a[i]); tot-=a[i]; grr++; }else{ //cerr<<a[i]<<"b\n"; all[a[i]].pb(tot-cur); if(tot-cur)grr++; break; } } map<int,int> it; cout<<n-grr<<"\n"; for(int i=0;i<n;i++){ if(it[vol[i]]<all[vol[i]].size()){ cout<<all[vol[i]][it[vol[i]]]<<" "; it[vol[i]]++; }else cout<<"0 "; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #ifndef ONLINE_JUDGE #ifndef INTERACTIVE freopen("in","r",stdin); #endif freopen("out","w",stdout); #endif int t=1; //cin>>t; while (t--) { solve(); } }

Compilation message (stderr)

psk.cpp: In function 'void solve()':
psk.cpp:53:22: warning: comparison of integer expressions of different signedness: 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         if(it[vol[i]]<all[vol[i]].size()){
psk.cpp: In function 'int main()':
psk.cpp:66:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     freopen("in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~
psk.cpp:68:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     freopen("out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...