답안 #85962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85962 2018-11-23T12:09:12 Z Nordway 금 캐기 (IZhO14_divide) C++14
0 / 100
1000 ms 4700 KB
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0)
#define FILE "divide"

using namespace std;


typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const int mod=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const ld pi=acos(-1);
const int N=1e5+5;

ll g[N],x[N],d[N],sum[N],p[N];

int main(){
	/*freopen(FILE".in","r",stdin);
	freopen(FILE".out","w",stdout);*/
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>g[i]>>d[i];
		p[i]=p[i-1]+d[i];
		sum[i]=sum[i-1]+g[i];
	}
	ll res=0;
	for(int i=1;i<=n;i++){
		int l=i,r=n;
		int ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(p[mid]-p[i-1]>=x[mid]-x[i])ans=mid,l=mid+1;
			else r=mid;
		}
      	if(ans==0)continue;
		res=max(res,sum[ans]-sum[i-1]);
	}
	cout<<res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 1070 ms 376 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 408 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Execution timed out 1075 ms 512 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 14 ms 972 KB Output is correct
3 Correct 20 ms 972 KB Output is correct
4 Correct 79 ms 2528 KB Output is correct
5 Correct 74 ms 2540 KB Output is correct
6 Correct 200 ms 4584 KB Output is correct
7 Correct 112 ms 4584 KB Output is correct
8 Correct 114 ms 4584 KB Output is correct
9 Correct 128 ms 4700 KB Output is correct
10 Execution timed out 1085 ms 4700 KB Time limit exceeded
11 Halted 0 ms 0 KB -