# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
922353 | Shayan86 | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 4572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define kill(res) cout << res << '\n', exit(0);
#define set_dec(x) cout << fixed << setprecision(x);
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5 + 50;
const ll Mod = 1e9 + 7;
ll n, sum, a[N], b[N], c[N];
vector<pii> vec;
int main(){
fast_io;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i];
vec.pb({b[i], i}); sum += a[i];
}
sort(all(vec)); reverse(all(vec));
int res = n;
for(int i = 0; i < n; i++){
c[vec[i].S] = min(1ll * vec[i].F, sum);
sum -= c[vec[i].S]; res--;
if(!sum) break;
}
cout << res << endl;
for(int i = 1; i <= n; i++) cout << c[i] << sep;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |