답안 #941871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941871 2024-03-09T15:36:13 Z pcc 금 캐기 (IZhO14_divide) C++17
100 / 100
23 ms 7264 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const ll inf = 1e9;
const int mxn = 1e5+10;
int N;
array<ll,3> arr[mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N;
	for(int i = 1;i<=N;i++){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
		arr[i][1] += arr[i-1][1];
		arr[i][2] += arr[i-1][2];
	}
	ll ans = 0;
	vector<pll> v;
	for(int i = 1;i<=N;i++){
		if(v.empty()||v.back().fs>arr[i-1][2]-(arr[i][0]))v.push_back(pll(arr[i-1][2]-(arr[i][0]),i));
		auto it = lower_bound(v.rbegin(),v.rend(),pll(arr[i][2]-arr[i][0],inf));
		if(it != v.rbegin()){
			it--;
			ans = max(ans,arr[i][1]-arr[it->sc-1][1]);
		}
	}
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 484 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 484 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 2 ms 860 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 3 ms 2652 KB Output is correct
28 Correct 10 ms 3704 KB Output is correct
29 Correct 11 ms 3932 KB Output is correct
30 Correct 23 ms 5468 KB Output is correct
31 Correct 19 ms 4468 KB Output is correct
32 Correct 23 ms 4436 KB Output is correct
33 Correct 21 ms 4376 KB Output is correct
34 Correct 19 ms 5584 KB Output is correct
35 Correct 22 ms 7128 KB Output is correct
36 Correct 23 ms 7264 KB Output is correct