# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
671672 | 2022-12-13T12:56:59 Z | ReLice | 금 캐기 (IZhO14_divide) | C++17 | 66 ms | 51148 KB |
#include<bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define ld long double #define int long long #define pb push_back #define sz size() #define fr first #define sc second //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N=1e6+5; const int mod=1e9+7; const int inf=1e7; vector <ll> x(N),g(N),a(N),pref(N),pref2(N); map<ll,vector<ll>> mp ; void solve(){ ll n,i,mx=-1,l,r,k; cin>>n; ll suf[n]; for(i=0;i<n;i++) cin>>x[i]>>g[i]>>a[i]; pref[0]=a[0]; pref2[0]=g[0]; for (i=1;i<n;i++){ pref[i]=pref[i-1]; pref[i]+=a[i]; pref2[i]=pref2[i-1]+g[i]; mp[pref[i]].pb(i); } suf[n-1]=pref[n-1]-x[n-1]; for(ll i=n-2;i>=0;i--) suf[i] = max(suf[i + 1], pref[i] - x[i]); for(ll i=0;i<n;i++){ k=-x[i]; if(i>0)k+=pref[i-1]; l=i; r=n; while(l+1<r){ ll mid=(l+r)>>1; if(suf[mid]>=k) l=mid; else r=mid; } mx=max(mx,pref2[l]-pref2[i]+g[i]); } cout<<mx<<endl; } signed main(){ //fre("divide"); start(); ll t=1; //cin>>t; while(t--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 39380 KB | Output is correct |
2 | Correct | 14 ms | 39464 KB | Output is correct |
3 | Correct | 15 ms | 39380 KB | Output is correct |
4 | Correct | 14 ms | 39380 KB | Output is correct |
5 | Correct | 14 ms | 39364 KB | Output is correct |
6 | Correct | 15 ms | 39380 KB | Output is correct |
7 | Correct | 15 ms | 39440 KB | Output is correct |
8 | Correct | 15 ms | 39432 KB | Output is correct |
9 | Correct | 16 ms | 39380 KB | Output is correct |
10 | Correct | 16 ms | 39380 KB | Output is correct |
11 | Correct | 14 ms | 39380 KB | Output is correct |
12 | Correct | 14 ms | 39452 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 39380 KB | Output is correct |
2 | Correct | 14 ms | 39464 KB | Output is correct |
3 | Correct | 15 ms | 39380 KB | Output is correct |
4 | Correct | 14 ms | 39380 KB | Output is correct |
5 | Correct | 14 ms | 39364 KB | Output is correct |
6 | Correct | 15 ms | 39380 KB | Output is correct |
7 | Correct | 15 ms | 39440 KB | Output is correct |
8 | Correct | 15 ms | 39432 KB | Output is correct |
9 | Correct | 16 ms | 39380 KB | Output is correct |
10 | Correct | 16 ms | 39380 KB | Output is correct |
11 | Correct | 14 ms | 39380 KB | Output is correct |
12 | Correct | 14 ms | 39452 KB | Output is correct |
13 | Correct | 14 ms | 39424 KB | Output is correct |
14 | Correct | 14 ms | 39380 KB | Output is correct |
15 | Correct | 14 ms | 39500 KB | Output is correct |
16 | Correct | 18 ms | 39500 KB | Output is correct |
17 | Correct | 15 ms | 39520 KB | Output is correct |
18 | Correct | 15 ms | 39728 KB | Output is correct |
19 | Correct | 16 ms | 39508 KB | Output is correct |
20 | Correct | 15 ms | 39508 KB | Output is correct |
21 | Correct | 15 ms | 39604 KB | Output is correct |
22 | Correct | 16 ms | 39684 KB | Output is correct |
23 | Correct | 17 ms | 40044 KB | Output is correct |
24 | Correct | 18 ms | 40132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 39380 KB | Output is correct |
2 | Correct | 14 ms | 39464 KB | Output is correct |
3 | Correct | 15 ms | 39380 KB | Output is correct |
4 | Correct | 14 ms | 39380 KB | Output is correct |
5 | Correct | 14 ms | 39364 KB | Output is correct |
6 | Correct | 15 ms | 39380 KB | Output is correct |
7 | Correct | 15 ms | 39440 KB | Output is correct |
8 | Correct | 15 ms | 39432 KB | Output is correct |
9 | Correct | 16 ms | 39380 KB | Output is correct |
10 | Correct | 16 ms | 39380 KB | Output is correct |
11 | Correct | 14 ms | 39380 KB | Output is correct |
12 | Correct | 14 ms | 39452 KB | Output is correct |
13 | Correct | 14 ms | 39424 KB | Output is correct |
14 | Correct | 14 ms | 39380 KB | Output is correct |
15 | Correct | 14 ms | 39500 KB | Output is correct |
16 | Correct | 18 ms | 39500 KB | Output is correct |
17 | Correct | 15 ms | 39520 KB | Output is correct |
18 | Correct | 15 ms | 39728 KB | Output is correct |
19 | Correct | 16 ms | 39508 KB | Output is correct |
20 | Correct | 15 ms | 39508 KB | Output is correct |
21 | Correct | 15 ms | 39604 KB | Output is correct |
22 | Correct | 16 ms | 39684 KB | Output is correct |
23 | Correct | 17 ms | 40044 KB | Output is correct |
24 | Correct | 18 ms | 40132 KB | Output is correct |
25 | Correct | 18 ms | 40020 KB | Output is correct |
26 | Correct | 21 ms | 40652 KB | Output is correct |
27 | Correct | 19 ms | 40660 KB | Output is correct |
28 | Correct | 38 ms | 45364 KB | Output is correct |
29 | Correct | 40 ms | 45260 KB | Output is correct |
30 | Correct | 66 ms | 51140 KB | Output is correct |
31 | Correct | 60 ms | 51140 KB | Output is correct |
32 | Correct | 62 ms | 51148 KB | Output is correct |
33 | Correct | 65 ms | 51144 KB | Output is correct |
34 | Correct | 65 ms | 51148 KB | Output is correct |
35 | Correct | 63 ms | 51124 KB | Output is correct |
36 | Correct | 65 ms | 51124 KB | Output is correct |