Submission #1319931

#TimeUsernameProblemLanguageResultExecution timeMemory
1319931minhpnkGym Badges (NOI22_gymbadges)C++20
0 / 100
73 ms8156 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(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...