# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844245 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// clang-format off
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lg2(x) (63 - __builtin_clzll(x))
#define db cerr << "BREAK\n"
#define fp(...) fprintf(stderr, __VA_ARGS__)
#define rs(a) a.resize(n)
#define hizli cin.tie(0);ios_base::sync_with_stdio(0)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(a, b) for (int a = 0; a < b; a++)
#define af(x) for(auto&a:x)fp("%d ",a);fp("\n")
#define ff first
#define ss second
#define zekochain main
// clang-format on
template <typename... Args> void in(Args &&...args) {
(std::cin >> ... >> args);
}
const int N = 2e5 + 5, MOD = 1e9 + 7;
struct bab{
ll li,vol,ind;
bool operator<(const bab &other){
return vol < other.vol;
}
};
int zekochain(){
int n;
cin >> n;
vector<bab> v(n);
for(int i=0;i<n;i++){
int a,b;
cin >> a >> b;
v[i]={a,-b,i};
}
ll sm = 0;
for(auto&i:v){
sm+=i.li;
}
sort(all(v));
vector<int> mp(n);
int i;
for( i=0;i<n && sm>0;i++){
mp[v[i].ind]=min(-v[i].vol,sm);
sm+=v[i].vol;
}
cout << n-i << endl;
for(auto&a:mp){
cout << a << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |