| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1335327 | minhpnk | Gym Badges (NOI22_gymbadges) | C++20 | 138 ms | 24440 KiB |
#include <bits/stdc++.h>
#define int long long
#define taskname "main"
#define debug(a, l, r) for (int _i = l; _i <= r; _i++) cout<<(a)[_i]<<' '; cout<<'\n'
#define debug_m(a, li, lj, ri, rj) for (int _i = li; _i <= ri; _i++){for (int _j = lj; _j <= rj; _j++) cout<<(a)[_i][_j]<<' '; cout<<'\n';} cout<<'\n'
using namespace std;
const int maxN = 1e6;
int n,
w[maxN + 1],
c[maxN + 1];
struct Box
{
int l, r;
inline int w()
{
return r - l;
}
void print()
{
cout << l << ' ' << r << '\n';
}
bool operator < (const Box &other) const
{
return r - l < other.r - other.l;
}
} a[maxN + 1];
priority_queue <Box> pq;
void init()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> w[i];
for (int i = 1; i <= n; i++)
cin >> c[i];
for (int i = 1; i <= n; i++)
a[i] = {c[i], c[i] + w[i]};
sort(a + 1, a + n + 1, [](Box &x, Box &y){
return x.r < y.r;
});
}
void solve()
{
int tmp_w = 0;
for (int i = 1; i <= n; i++)
{
pq.push(a[i]);
tmp_w += a[i].w();
while (tmp_w > a[i].r)
{
Box uv_max = pq.top();
tmp_w -= uv_max.w();
pq.pop();
}
}
cout << pq.size();
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
if (fopen("main.inp","r"))
{
freopen("main.inp","r",stdin);
freopen("main.out","w",stdout);
}
init(); solve();
}컴파일 시 표준 에러 (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... | ||||
