Submission #844272

#TimeUsernameProblemLanguageResultExecution timeMemory
844272vjudge1Pod starim krovovima (COCI20_psk)C++98
35 / 50
1 ms600 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b,c,d,p,h,y,u,n; vector <pair <long long,long long> > arr; vector <pair <long long,long long> > den; long long arr1[10005]; cin>>a; y=0; p=a; n=1; while(a--){ cin>>b>>c; y+=b; arr.push_back(make_pair(c,b)); den.push_back(make_pair(c,n-1)); n++; } d=0; sort(arr.begin(),arr.end(), greater <pair <long long, long long> >()); sort(den.begin(),den.end(), greater <pair <long long, long long> >()); for(long long i;p>i;i++){ if((arr[i].first - arr[i].second) <= y){ y-=arr[i].first; arr[i].second = arr[i].first; } else{ if(y == 0){ arr[i].second = 0; d++; } else{ arr[i].second = y; y=0; } } } for(long long i;p>i;i++){ arr1[den[i].second] = arr[i].second; } cout<<d<<"\n"; for(long long i;p>i;i++){ cout<<arr1[i]<<" "; } }

Compilation message (stderr)

psk.cpp: In function 'int main()':
psk.cpp:4:22: warning: unused variable 'h' [-Wunused-variable]
    4 |  long long a,b,c,d,p,h,y,u,n;
      |                      ^
psk.cpp:4:26: warning: unused variable 'u' [-Wunused-variable]
    4 |  long long a,b,c,d,p,h,y,u,n;
      |                          ^
psk.cpp:22:16: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  for(long long i;p>i;i++){
      |                ^
psk.cpp:38:16: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |  for(long long i;p>i;i++){
      |                ^
psk.cpp:42:2: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |  for(long long i;p>i;i++){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...