답안 #529669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529669 2022-02-23T10:31:02 Z Kenjikrab 금 캐기 (IZhO14_divide) C++14
17 / 100
1 ms 332 KB
#include<bits/stdc++.h>
#define ll long long
#define db double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define loop(i,j,k) for(int i=j;i<k;i++)
using namespace std;
signed main(){
	//ios_base::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	int ans=0;
	vector<int> x,g,p;
	x.pb(0);
	g.pb(0);
	p.pb(0);
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		x.pb(a);
		g.pb(g[i]+b);
		p.pb(p[i]+c);
	}
	vector<pii> diff;
	ans=g[n]-g[n-1];
	diff.pb({x[n]-p[n],g[n]});
	for(int i=n-1;i>0;i--){
		if(x[i]-p[i]<diff.back().fi) diff.pb({x[i]-p[i],g[i]});
		int con=x[i]-p[i-1];
		int l=0,r=diff.size()-1;
		while(l<r){
			int mid=(l+r)/2;
			if(diff[mid].fi>con) l=mid+1;
			else r=mid;
		}
		if(diff[l].fi<=con) ans=max(ans,diff[l].se-g[i-1]);
		else ans=max(ans,g[i]-g[i-1]);
	}
	cout<<ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Incorrect 1 ms 332 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Incorrect 1 ms 332 KB Output isn't correct
18 Halted 0 ms 0 KB -