Submission #734910

# Submission time Handle Problem Language Result Execution time Memory
734910 2023-05-03T09:08:04 Z DangerNoodle7591 Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define N 1005
#define big 1000000000000000007
int main(){
  lalala;
  int n;cin>>n;
  int top=0;
  int arr[n];
  memset(arr,0,sizeof(arr));
  vector<pair<int,int>> v;// volum index
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    top+=a;
    v.push_back({b,i});
  }
  sort(v.begin(),v.end(),greater<>());
  int cev=n;
  for(auto u:v){
    if(top==0)break;
    int vol=u.first,indek=u.second;
    cev--;
    if(vol>=top){
      arr[indek]=top;
      top=0;break;
    }
    top-=vol;
    arr[indek]=vol;
  }
  cout<<cev<<endl;
  for(int i=0;i<n;i++){
    cout<<arr[i]<<" ";
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct