Submission #844246

# Submission time Handle Problem Language Result Execution time Memory
844246 2023-09-05T11:48:07 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
20 / 50
1 ms 428 KB
// Imagine not FFT
#include <bits/stdc++.h>
 
#define fastio std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
#define DEBUG(...) void(23)
#define DEBUGV(x) void(23);
#define DEBUGARR(arr, size) void(23)
#define DEBUGPRINT(...) void(23)
#define DEBUGMAP(...) void(23)
#define DEBUGMAPQUEUE(...) void(23)
#define DEBUGVV(x) void(23);
#define DEBUGVP(x) void(23);
#define files void(23); 
 
#define int long long
#define ll long long
 
#define pb push_back
#define ff first
#define ss second
#define pii std::pair < int , int >
#define pll std::pair < ll , ll >
#define vi std::vector < ll >
#define vl std::vector < int >
#define vii std::vector < pii >
#define vll std::vector < pll >
#define vvi std::vector < vi >
#define vvii std::vector < vii >
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define forn(i,j) for(int i=0;i<j;i++)
#define forr(i,j,k) for(int i=j;i<k;i++)
 
#define mset multiset
#define pqueue priority_queue
#define cmax(a,b) (a = max(a,b))
#define cmin(a,b) (a = min(a,b))
 
#define sz(a) (int)(a.size())
 
#define yes std::cout << "YES\n";
#define no std::cout << "NO\n";
    
using namespace std;

void solve(int _t_case){
    DEBUG(_t_case);
    int n;
    cin >> n;
    set<pair<int,int>> a;
    int totLiquid=0;
    forn(i,n){int x,y;cin >> x >> y;a.insert({y,i});totLiquid+=x;}
    int anst = 0;
    vi ans(n);
    for(auto b:a){
        if(totLiquid==0) ++anst;
        ans[b.ss]=min(totLiquid,b.ff);
        totLiquid=max(totLiquid-b.ff,0ll);
    }
    cout << anst << endl;
    for(auto c:ans)
    	cout << c << " ";
    return;
}

signed main(){
    fastio;
    files;
    int t=1,_t=0;
//    std::cin >> t;
    while(_t<t){
        ++_t;
        solve(_t);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 1 ms 428 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct