답안 #680923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680923 2023-01-12T03:38:48 Z oblantis 금 캐기 (IZhO14_divide) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 12;
void solve() {
	int n;
	cin >> n;
	ll ans = 0;
	pair<ll, pll> p[n];
	for(int i = 0; i < n; i++) {
		cin >> p[i].ff >> p[i].ss.ff >> p[i].ss.ss;
		ans = max(ans, p[i].ss.ff);
	}
	sort(p, p + n);
	set<pll> s;
	s.insert({p[0].ff, 0});
	for(int i = 1; i < n; i++) {
		p[i].ss.ss += p[i - 1].ss.ss;
		p[i].ss.ff += p[i - 1].ss.ff;
		ll x = p[i].ff - p[i].ss.ss;
		auto j = s.lower_bound({x, 0});
		if(j != s.end()) {
			ans = max(ans, p[i].ss.ff - (*j).ss);
		}
		s.insert({p[i].ff - p[i - 1].ss.ss, p[i - 1].ss.ff});
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tcs = 1;
	//cin >> tcs;
	for(int i = 1; i <= tcs; i++) {
		solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -