Submission #99568

#TimeUsernameProblemLanguageResultExecution timeMemory
99568lovemathboyArt Exhibition (JOI18_art)C++14
100 / 100
285 ms21064 KiB
#include <bits/stdc++.h>
using namespace std;

int n;
vector<pair<long long, int> > a;

int main() {
	scanf("%d", &n);
	long long i1;
	int i2;
	for (int i = 0; i < n; i++) {
		scanf("%lld %d", &i1, &i2);
		a.emplace_back(i1, i2);
	}
	sort(a.begin(), a.end());
	long long maxi = 0, sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		maxi = max(maxi, a[i].first - sum);
		sum += a[i].second;
		ans = max(ans, sum - a[i].first + maxi);
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:8: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 %d", &i1, &i2);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...