Submission #708646

#TimeUsernameProblemLanguageResultExecution timeMemory
708646PixelCatTwo Dishes (JOI19_dishes)C++14
0 / 100
2 ms468 KiB
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define sz(x) ((int)x.size()) #define all(x) x.begin(), x.end() #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; const int MAXN = 1000010; struct OWO { int a, s, p; }; OWO a[MAXN]; OWO b[MAXN]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // NYA =^-w-^= int n, m; cin >> n >> m; int nowt = 0; For(i, 1, n) { auto &owo = a[i]; cin >> owo.a >> owo.s >> owo.p; assert(owo.p == 1); nowt += owo.a; } For(i, 1, m) { auto &owo = b[i]; cin >> owo.a >> owo.s >> owo.p; assert(owo.p == 1); nowt += owo.a; } int i = n, j = m; int ans = 0; while(i || j) { int sel = -1; // 1 for a, 2 for b if(i == 0) sel = 2; else if(j == 0) sel = 1; else if(nowt <= a[i].s) sel = 1; else if(nowt <= b[j].s) sel = 2; else if(a[i].a > b[i].a) sel = 1; else sel = 2; if(sel == 1) { ans += (nowt <= a[i].s); nowt -= a[i].a; i--; } else { ans += (nowt <= b[j].s); nowt -= b[j].a; j--; } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...