# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
671830 | 2022-12-14T03:57:42 Z | moday_morning | 금 캐기 (IZhO14_divide) | C++17 | 0 ms | 212 KB |
#include <bits/stdc++.h> #define int long long #define fr first #define sc second #define pb push_back using namespace std; void usaco(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve() { int n; cin >> n; int x[n+1], g[n+1], d[n+1]; d[0] = 0; g[0] = 0; for (int i = 1; i <= n; i++) { cin >> x[i] >> g[i] >> d[i]; d[i] += d[i-1]; g[i] += g[i-1]; } vector <pair <int, int>> a, b; a.pb({INT_MIN, INT_MIN}); b.pb({INT_MIN, INT_MIN}); for(int i = 1; i <= n; i++) { a.pb({d[i] - x[i], g[i]}); b.pb({d[i-1] - x[i], - g[i-1]}); } sort(a.begin(), a.end()); sort(b.begin(), b.end()); int sb = INT_MIN, res = 0, ans = 0, cnt = 0; for (ans = 1; ans <= n; ans++) { while (cnt+1 <= n && b[cnt+1].fr <= a[ans].fr) { cnt++; sb = max(sb, b[cnt].sc); } res = max(res, a[ans].sc + sb); } cout << res << "\n"; } signed main() { // usaco("triangles"); ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Incorrect | 0 ms | 212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Incorrect | 0 ms | 212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Incorrect | 0 ms | 212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |