# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
844874 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int int64_t
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
#define F first
#define S second
#define I insert
#define PB push_back
#define POB pop_back
#define sqr(a) ((a) * (a))
#define P pop
#define max3(a, b, c) (max(a, max(b, c)))
#define max4(a, b, c, d) (max(max(a, b), max(c, d)))
#define min3(a, b, c) (min(a, min(b, c)))
#define min4(a, b, c, d) (min(min(a, b), min(c, d)))
#define MOD 1000000007
#define mod 998244353
int binpow(int a, int p, int m = MOD) {
int ans = 1;
while (p) {
if (p & 1) ans = ((ans % m) * (a % m)) % m;
a = sqr(a) % m;
p >>= 1;
}
return ans;
}
void solve() {
int n;
cin >> n;
vector<pair<int, int>> z(n, {0, 0});
int liqu = 0;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp >> z[i].F;
liqu += tmp;
z[i].S = i;
}
sort(z.rbegin(), z.rend());
vector<pair<int, int>> ans(n, {0, 0});
int ansi = 0;
for (int i = 0; i < n; i++) {
ans[i].F = z[i].S;
ans[i].S = min(z[i].F, liqu);
liqu -= ans[i].S;
if (ans[i].S == 0) ansi++;
}
sort(ans.begin(), ans.end());
cout << ansi << endl;
for (int i = 0; i < n; i++) {
cout << ans[i].S;
if (i != n - 1) cout << ' ';
}
}
int32_t main() {
int t = 1;
while (t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |