답안 #91518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91518 2018-12-28T03:50:47 Z SOIVIEONE 금 캐기 (IZhO14_divide) C++14
0 / 100
169 ms 16128 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll x[N], g[N], e[N], dp[N], pd[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> x[i] >> g[i] >> e[i],
		dp[i] += dp[i - 1] + e[i],
		pd[i] += pd[i - 1] + g[i];
	ll ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int l = i, r = n;
		for(int j = 1; j <= 30; j ++)
		{
			int m = (l + r) >> 1;
			if(dp[m] - dp[i-1] < x[r] - x[i-1])
				r = m;
			else
				l = m+1;
		}
		umin(l, r);
		umax(ans, (ll)(pd[l] - pd[i - 1]));
	}
	cout << ans;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Incorrect 2 ms 588 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 840 KB Output is correct
2 Correct 9 ms 1012 KB Output is correct
3 Correct 11 ms 1060 KB Output is correct
4 Correct 52 ms 2608 KB Output is correct
5 Correct 62 ms 3876 KB Output is correct
6 Correct 169 ms 8932 KB Output is correct
7 Correct 96 ms 10716 KB Output is correct
8 Correct 97 ms 12672 KB Output is correct
9 Correct 92 ms 14372 KB Output is correct
10 Incorrect 93 ms 16128 KB Output isn't correct
11 Halted 0 ms 0 KB -