Submission #844301

# Submission time Handle Problem Language Result Execution time Memory
844301 2023-09-05T12:10:59 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
0 / 50
1 ms 600 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void solve()
{
  int n;
  cin >> n;
  vector<array<int,3>> ans;
  int go[n+1];
  
  int hm=0;
  for(int i=1;i<=n;i++)
  {
   int a,b;
   cin >> a >> b;
   hm+=a;
   ans.pb({b,a,i});
  }
  
  sort(rall(ans));
  
  for(int i=0;i<n;i++)
  {
    if(hm>ans[i][0])
    {
      hm-=ans[i][0];
      go[ans[i][2]]=ans[i][0];
    }
    else
    {
      go[ans[i][2]]=hm;
      break;
    }
  }


  int sum=0;
  for(int i=1;i<=n;i++) sum+=(go[i]==0);

  for(int i=1;i<=n;i++) cout << go[i] << " \n"[i==n]; 
}

int32_t main(){

  cin.tie(0); ios::sync_with_stdio(0);
  
  int t=1;//cin >> t;
  while(t--) solve();

  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 70 violates the range [0, 9]
2 Incorrect 0 ms 344 KB Integer 9 violates the range [0, 8]
3 Incorrect 0 ms 344 KB Integer 6103064 violates the range [0, 10]
4 Incorrect 0 ms 344 KB Output isn't correct
5 Incorrect 0 ms 344 KB Integer 28 violates the range [0, 20]
6 Incorrect 0 ms 600 KB Output isn't correct
7 Incorrect 1 ms 344 KB Output isn't correct
8 Incorrect 1 ms 344 KB Output isn't correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 Incorrect 1 ms 344 KB Output isn't correct