Submission #48472

#TimeUsernameProblemLanguageResultExecution timeMemory
48472arman_ferdousArt Exhibition (JOI18_art)C++17
0 / 100
2 ms248 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...