Submission #235481

# Submission time Handle Problem Language Result Execution time Memory
235481 2020-05-28T10:58:01 Z ruler Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 384 KB
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 5e5 + 5;

int A[N], B[N], P[N];
ll DP[N], S[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> A[i] >> B[i], P[i] = i;
	sort(P + 1, P + 1 + n, [&](int i, int j) { return A[i] < A[j]; });
	for (int i = 1; i <= n; i++) {
		S[i] = max(S[i - 1] + B[P[i]], 1LL * (B[P[i]] + A[P[i]]));
		DP[i] = max(DP[i - 1], S[i] - A[P[i]]);
	}
	cout << DP[n] << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -