# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20827 | 2017-02-23T01:37:38 Z | kdh9949 | 금 캐기 (IZhO14_divide) | C++14 | 73 ms | 4824 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, x[100010], sz; ll g[100010], e[100010], ans; vector<int> v; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d%lld%lld", x + i, g + i, e + i); g[i] += g[i - 1]; e[i] += e[i - 1]; } for(int i = n, s, en; i >= 1; i--){ while(sz > 1 && 1L * (e[i - 1] - e[v[sz - 1]]) / (x[i] - x[v[sz - 1]]) < 1L * (e[v[sz - 1]] - e[v[sz - 2]]) / (x[v[sz - 1]] - x[v[sz - 2]])){ v.pop_back(); sz--; } v.push_back(i); sz++; s = 0; en = sz - 1; while(s <= en){ int m = (s + en) / 2; if(e[v[m] - (v[m] == i)] - e[i - 1] >= x[v[m]] - x[i]) en = m - 1; else s = m + 1; } ans = max(ans, g[v[s]] - g[i - 1]); v.pop_back(); sz--; while(sz > 1 && 1L * (e[i] - e[v[sz - 1]]) / (x[i] - x[v[sz - 1]]) < 1L * (e[v[sz - 1]] - e[v[sz - 2]]) / (x[v[sz - 1]] - x[v[sz - 2]])){ v.pop_back(); sz--; } v.push_back(i); sz++; } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3972 KB | Output is correct |
2 | Correct | 0 ms | 3972 KB | Output is correct |
3 | Correct | 0 ms | 3972 KB | Output is correct |
4 | Correct | 0 ms | 3972 KB | Output is correct |
5 | Correct | 0 ms | 3972 KB | Output is correct |
6 | Correct | 0 ms | 3972 KB | Output is correct |
7 | Correct | 0 ms | 3972 KB | Output is correct |
8 | Correct | 0 ms | 3972 KB | Output is correct |
9 | Correct | 0 ms | 3972 KB | Output is correct |
10 | Correct | 0 ms | 3972 KB | Output is correct |
11 | Correct | 0 ms | 3972 KB | Output is correct |
12 | Correct | 0 ms | 3972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3972 KB | Output is correct |
2 | Correct | 0 ms | 3972 KB | Output is correct |
3 | Correct | 0 ms | 3972 KB | Output is correct |
4 | Correct | 0 ms | 3972 KB | Output is correct |
5 | Correct | 0 ms | 3972 KB | Output is correct |
6 | Correct | 0 ms | 3972 KB | Output is correct |
7 | Correct | 0 ms | 3972 KB | Output is correct |
8 | Correct | 0 ms | 3972 KB | Output is correct |
9 | Correct | 0 ms | 3972 KB | Output is correct |
10 | Correct | 0 ms | 3972 KB | Output is correct |
11 | Correct | 0 ms | 4112 KB | Output is correct |
12 | Correct | 3 ms | 4112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3972 KB | Output is correct |
2 | Correct | 3 ms | 3972 KB | Output is correct |
3 | Correct | 3 ms | 3972 KB | Output is correct |
4 | Correct | 23 ms | 3972 KB | Output is correct |
5 | Correct | 26 ms | 3972 KB | Output is correct |
6 | Correct | 73 ms | 3972 KB | Output is correct |
7 | Correct | 46 ms | 3972 KB | Output is correct |
8 | Correct | 39 ms | 3972 KB | Output is correct |
9 | Correct | 39 ms | 3972 KB | Output is correct |
10 | Correct | 43 ms | 4440 KB | Output is correct |
11 | Correct | 49 ms | 4824 KB | Output is correct |
12 | Correct | 46 ms | 4824 KB | Output is correct |