# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
86763 | 2018-11-27T09:43:33 Z | Mercenary | 금 캐기 (IZhO14_divide) | C++11 | 71 ms | 10588 KB |
#include<bits/stdc++.h> #define pb push_back #define brokenheart "TEST" using namespace std; typedef long long ll; typedef long double ld; const int maxn = 1e5 + 5; #define int ll int n; int x[maxn] , r[maxn] , g[maxn] , dis[maxn]; int bit[maxn] , cost[maxn] , c[maxn] , sum[maxn]; vector<pair<int,int>> v; void enter() { cin >> n; for(int i = 1 ; i <= n ; ++i) cin >> x[i] >> g[i] >> r[i]; for(int i = 1 ; i < n ; ++i) dis[i] = x[i + 1] - x[i]; for(int i = 1 ; i < n ; ++i){ cost[i] = cost[i - 1] + dis[i] - r[i]; v.pb({cost[i],i}); } v.pb({0,0}); sort(v.begin(),v.end()); for(int i = 1 ; i <= n ; ++i) sum[i] = sum[i - 1] + g[i]; int cnt = 1; c[v[0].second] = 1; vector<pair<int,int>> v1; v1.push_back(v[0]); for(int i = 1 ; i < v.size() ; ++i) { if(v[i].first == v[i - 1].first)c[v[i].second] = cnt; else c[v[i].second] = ++cnt ,v1.push_back(v[i]); } v = v1; } void update(int pos , int x) { for( ; pos < maxn ; pos += pos & -pos) bit[pos] = min(bit[pos],x); } int query(int pos) { int res = maxn; for( ; pos > 0 ; pos &= pos - 1) res = min(res , bit[pos]); return res; } void solve() { fill_n(bit , maxn , maxn); ll res = 0; for(int i = 1 ; i <= n ; ++i) { int pos = upper_bound(v.begin(),v.end(),make_pair(r[i] - cost[i - 1] , 0ll)) - v.begin(); int ans = query(pos); // cout << pos << " " << ans << endl; if(ans != maxn)res = max(res , sum[i] - sum[ans]); if(i != n)update(c[i] , i - 1); res = max(res , g[i]); } cout << res; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if(fopen(brokenheart".INP","r")) freopen(brokenheart".INP","r",stdin) , freopen(brokenheart".OUT","w",stdout); enter(); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1144 KB | Output is correct |
2 | Incorrect | 3 ms | 1152 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1192 KB | Output is correct |
2 | Correct | 3 ms | 1364 KB | Output is correct |
3 | Incorrect | 3 ms | 1380 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1724 KB | Output is correct |
2 | Correct | 9 ms | 2160 KB | Output is correct |
3 | Correct | 7 ms | 2164 KB | Output is correct |
4 | Correct | 27 ms | 5524 KB | Output is correct |
5 | Correct | 36 ms | 5524 KB | Output is correct |
6 | Correct | 71 ms | 10384 KB | Output is correct |
7 | Correct | 63 ms | 10460 KB | Output is correct |
8 | Correct | 63 ms | 10464 KB | Output is correct |
9 | Correct | 50 ms | 10464 KB | Output is correct |
10 | Incorrect | 56 ms | 10588 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |