Submission #42268

# Submission time Handle Problem Language Result Execution time Memory
42268 2018-02-24T18:53:39 Z RezwanArefin01 Art Exhibition (JOI18_art) C++14
0 / 100
1 ms 248 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii; 

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n; cin >> n; 
	vector<ii> p(n);
	for(int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p.begin(), p.end());

	for(int i = 1; i < n; i++) 
		p[i].second += p[i - 1].second;

	ll cmx = p[0].first, Max = p[0].second;
	for(int i = 1; i < n; i++) {
		Max = max(Max, p[i].second - p[i].first + cmx);
		cmx = max(cmx, p[i].first - p[i - 1].second);
	}
	cout << Max << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -