답안 #38707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38707 2018-01-06T09:28:51 Z khohko 금 캐기 (IZhO14_divide) C++14
17 / 100
166 ms 11396 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define N ((ll)(2e5+100))
#define ARRS ((ll)(2e5+100))
#define MOD ((ll)(1e9+7))

ll er[ARRS];
ll dp[ARRS];
ll dc[ARRS];
ll n;
struct va{
	ll x,g,c;
};
va a[ARRS];


int main(){
	//freopen("divide.in","r",stdin);
	//freopen("divide.out","w+",stdout);
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i].x>>a[i].g>>a[i].c;
	}
	ll pas=0;
	er[n]=n+1;
	for(int i=n-1; i>=0; i--){
		er[i]=i+1;
		dc[i]=a[i].c;
		dp[i]=a[i].g;
		while(er[i]<n){
				//cout<<i<<" "<<a[er[er[i]]-1].x-a[i].x<<" < "<<dc[i]<<" "<<dc[er[i]]<<" "<<er[er[i]]<<endl;
			if(a[er[er[i]]-1].x-a[i].x<=dc[i]+dc[er[i]]){

				dp[i]+=dp[er[i]];
				dc[i]+=dc[er[i]];
				er[i]=er[er[i]];
			}
			else break;
		}
		pas=max(pas,dp[i]);
	}
	cout<<pas;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 11396 KB Output is correct
2 Correct 0 ms 11396 KB Output is correct
3 Correct 0 ms 11396 KB Output is correct
4 Correct 0 ms 11396 KB Output is correct
5 Correct 0 ms 11396 KB Output is correct
6 Correct 0 ms 11396 KB Output is correct
7 Correct 0 ms 11396 KB Output is correct
8 Correct 0 ms 11396 KB Output is correct
9 Correct 0 ms 11396 KB Output is correct
10 Correct 0 ms 11396 KB Output is correct
11 Correct 0 ms 11396 KB Output is correct
12 Correct 0 ms 11396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 11396 KB Output is correct
2 Correct 0 ms 11396 KB Output is correct
3 Correct 0 ms 11396 KB Output is correct
4 Incorrect 0 ms 11396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11396 KB Output is correct
2 Correct 9 ms 11396 KB Output is correct
3 Correct 13 ms 11396 KB Output is correct
4 Correct 69 ms 11396 KB Output is correct
5 Correct 83 ms 11396 KB Output is correct
6 Correct 166 ms 11396 KB Output is correct
7 Correct 109 ms 11396 KB Output is correct
8 Correct 99 ms 11396 KB Output is correct
9 Correct 89 ms 11396 KB Output is correct
10 Incorrect 113 ms 11396 KB Output isn't correct
11 Halted 0 ms 0 KB -