제출 #844285

#제출 시각아이디문제언어결과실행 시간메모리
844285vjudge1Pod starim krovovima (COCI20_psk)C++17
0 / 50
353 ms80212 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]; } int res[n]; memset(res,0,sizeof(res)); int c=0; while(tot){ int maxi=-1; for(int i=0;i<n;i++){ if(!res[i]&&(maxi==-1||vol[maxi]<vol[i])){ maxi=i; } } if(tot<=vol[maxi]){ res[maxi]=tot; tot=0; c++; }else{ tot-=vol[maxi]; res[maxi]=vol[maxi]; c++; } } cout<<n-c<<"\n"; for(int i:res)cout<<i<<" "; } 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(); } }

컴파일 시 표준 에러 (stderr) 메시지

psk.cpp: In function 'int main()':
psk.cpp:64:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |     freopen("in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~
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("out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...