| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1319929 | minhpnk | Gym Badges (NOI22_gymbadges) | C++20 | 1 ms | 332 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,
dp[maxN + 1];
struct Gym
{
int x, l;
bool operator < (const Gym &other) const
{
return l < other.l;
}
void print()
{
cout << x << ' ' << l << '\n';
}
} a[maxN + 1];
stack <int> st;
void init()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].x;
for (int i = 1; i <= n; i++)
cin >> a[i].l;
sort(a + 1, a + n + 1);
}
void solve()
{
int tmp_sum = 0;
for (int i = 1; i <= n; i++)
{
while (!st.empty() && tmp_sum > a[i].l)
{
tmp_sum -= st.top();
st.pop();
}
st.push(a[i].x);
tmp_sum += a[i].x;
}
cout << st.size();
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen(taskname".inp","r",stdin);
freopen(taskname".out","w",stdout);
#endif
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... | ||||
