Submission #272077

#TimeUsernameProblemLanguageResultExecution timeMemory
272077okaragulArt Exhibition (JOI18_art)C++17
100 / 100
329 ms21112 KiB
#include<bits/stdc++.h>
using namespace std;

#define lli long long
#define INF LONG_LONG_MAX
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define endl '\n'
#define max(aa, bb) (aa > bb ? aa:bb)
#define min(aa, bb) (aa < bb ? aa:bb)
#define all(aa) aa.begin(), aa.end()

int main(){
	lli n;
	scanf("%lld", &n);
	
	vector<pair<lli,lli>>v(n);
	for(auto &it:v){
		scanf("%lld %lld", &it.st, &it.nd);
	}

	sort(all(v));

	lli tmp=v[0].nd, cvp=0;

	for(lli i=1;i<n;i++){
		tmp=max(tmp-v[i].st+v[i-1].st+v[i].nd, v[i].nd);
		cvp=max(cvp, tmp);
	}
	printf("%lld ", cvp);
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
art.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf("%lld %lld", &it.st, &it.nd);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...