답안 #488408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488408 2021-11-18T19:51:41 Z ammar2000 Pod starim krovovima (COCI20_psk) C++17
50 / 50
1 ms 336 KB
/*
      ___           ___           ___           ___           ___
     /  /\         /__/\         /__/\         /  /\         /  /\
    /  /::\         ::\         |::\       /  /::\       /  /::\
   /  /:/\:\      |  |:|:\      |  |:|:\     /  /:/\:\     /  /:/\:\
  /  /:/~/::\   __|__|:|\:\   __|__|:|\:\   /  /:/~/::\   /  /:/~/:/
 /__/:/ /:/\:\ /__/::::| \:\ /__/::::| \:\ /__/:/ /:/\:\ /__/:/ /:/___
 \  \:\/:/__\/ \  \:\~~\__\/ \  \:\~~\__\/ \  \:\/:/__\/ \  \:\/:::::/
  \  \::/       \  \:\        \  \:\        \  \::/       \  \::/~~~~
   \  \:\        \  \:\        \  \:\        \  \:\        \  \:\
    \  \:\        \  \:\        \  \:\        \  \:\        \  \:\
     \__\/         \__\/         \__\/         \__\/         \__\/
      ___                         ___         ___           ___           ___           ___
     /  /\                       /  /\       /__/\         /  /\         /  /\         /__/\
    /  /::\    ___              /  /::\      \  \:\       /  /:/_       /  /:/_        \  \:\
   /  /:/\:\  /__/\     ___    /  /:/\:\      \__\:\     /  /:/ /\     /  /:/ /\        \  \:\
  /  /:/~/::\ \  \:\   /  /\  /  /:/~/:/  ___ /  /::\   /  /:/ /:/_   /  /:/ /:/_   _____\__\:\
 /__/:/ /:/\:\ \  \:\ /  /:/ /__/:/ /:/  /__/\  /:/\:\ /__/:/ /:/ /\ /__/:/ /:/ /\ /__/::::::::\
 \  \:\/:/__\/  \  \:\  /:/  \  \:\/:/   \  \:\/:/__\/ \  \:\/:/ /:/ \  \:\/:/ /:/ \  \:\~~\~~\/
  \  \::/        \  \:\/:/    \  \::/     \  \::/       \  \::/ /:/   \  \::/ /:/   \  \:\  ~~~
   \  \:\         \  \::/      \  \:\      \  \:\        \  \:\/:/     \  \:\/:/     \  \:\
    \  \:\         \__\/        \  \:\      \  \:\        \  \::/       \  \::/       \  \:\
     \__\/                       \__\/       \__\/         \__\/         \__\/         \__\/


               _       __
  ___ ___   __| | ___ / _| ___  _ __ ___ ___  ___ _
 / __/ _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __(_)
| (_| (_) | (_| |  __/  _| (_) | | | (_|  __/\__ \_
 \___\___/ \__,_|\___|_|  \___/|_|  \___\___||___(_)

                                     ____   ___   ___   ___
  __ _ _ __ ___  _ __ ___   __ _ _ _|___ \ / _ \ / _ \ / _ \
 / _` | '_ ` _ \| '_ ` _ \ / _` | '__|__) | | | | | | | | | |
| (_| | | | | | | | | | | | (_| | |  / __/| |_| | |_| | |_| |
 \__,_|_| |_| |_|_| |_| |_|\__,_|_| |_____|\___/ \___/ \___/



*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int MOD=1e9+7;
ll n,sum,ans[SI],sth;
vector <pair <ll,ll> > p;
void solver()
{
    cin>>n;
    for (int i=0;i<n;i++)
    {
        ll b;
        cin>>b;
        sum+=b;
        ll a;
        cin>>a;
        p.pb({a,i});
    }
    sort (p.begin(),p.end());
    for (int i=n-1;i>=0&&sum>0;i--)
    {
        ans[p[i].S]=min(p[i].F,sum);
        sum-=p[i].F;
        sth++;
    }
    cout <<n-sth<<"\n";
    for (int i=0;i<n;i++)
        cout <<ans[i]<<" ";
}
int main()
{
   solver();
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct