Submission #48472

# Submission time Handle Problem Language Result Execution time Memory
48472 2018-05-13T18:42:25 Z arman_ferdous Art Exhibition (JOI18_art) C++17
0 / 100
2 ms 248 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 5e5+10;

pair<ll,ll> arr[N];
int main() {
	int n, L = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%lld %lld", &arr[i].first, &arr[i].second);
	sort(arr,arr+n);
	ll ans = 0, sum = 0;
	while(L+1 < n && arr[L+1].first >= arr[L].first + arr[L].second) L++;
	for(int R = L; R < n; R++) {
		sum += arr[R].second;
		ans = max(ans, sum - arr[R].first + arr[L].first);
	}
	printf("%lld", ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &arr[i].first, &arr[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -