| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1353446 | silverwolf | Gym Badges (NOI22_gymbadges) | C++20 | 0 ms | 360 KiB |
/*
tags: usaco | codeforces | centroid_decomposition
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::complex_literals;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define ll long long
#define mask(i) (1 << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define onbit(x, i) ((x) = (x) | mask(i))
#define offbit(x, i) ((x) = (x) & (~mask(i)))
#define pcount(i) __builtin_popcount(i)
#define bctz(i) __builtin_ctz(i)
#define all(v) v.begin(), v.end()
#define all1(v) v.begin()+1, v.end()
#define sz(v) (int)v.size()
#define sqr(x) ((x) * (x))
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define FORD(i,l,r) for(int i=(l);i>=(r);i--)
#define REP(i, r) for(int i=0;i<(r);i++)
#define BITSET(size, x) std::bitset<size + 1>(x).to_string().c_str()
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define complex complex<long double>
#define ite std::vector<int>::iterator
// #define int ll
template <class T> bool minimize(T& x,T y) {
if (x > y) x = y; else return 0; return 1;
}
template <class T> bool maximize(T& x,T y) {
if (x < y) x = y; else return 0; return 1;
}
// const ll INF = 1e9 + 2;
inline void solve()
{
int n;
cin >> n;
int X[n+1];
int L[n+1];
int con[n+1];
for(int i = 1; i <= n;i++) {
cin >> X[i];
}
for(int i = 1; i <= n;i++) {
cin >> L[i];
con[i] = X[i] + L[i];
}
sort(con + 1, con + n + 1);
priority_queue<int, vi> maxqueue;
ll s = 0;
for(int i = 1; i <= n; i++) {
if(s <= L[i]) {
s += X[i];
maxqueue.push(X[i]);
} else if(X[i] < maxqueue.top()) {
s = s - maxqueue.top() + X[i];
maxqueue.pop();
maxqueue.push(X[i]);
}
}
cout << maxqueue.size() << '\n';
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
