Submission #170279

#TimeUsernameProblemLanguageResultExecution timeMemory
170279AkashiArt Exhibition (JOI18_art)C++14
100 / 100
277 ms21112 KiB
#include <bits/stdc++.h> using namespace std; struct art{ long long x; int y; bool operator < (const art &aux)const{ if(x != aux.x) return x < aux.x; return y < aux.y; } }; int n; art a[500005]; int main() { scanf("%d", &n); for(int i = 1; i <= n ; ++i) scanf("%lld%d", &a[i].x, &a[i].y); sort(a + 1, a + n + 1); long long Sol = a[1].y, Sum = a[1].y, Max = a[1].x; for(int i = 2; i <= n ; ++i){ Max = max(Max, -Sum + a[i].x); Sum = Sum + a[i].y; Sol = max(Sol, Sum + Max - a[i].x); } printf("%lld", Sol); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%d", &a[i].x, &a[i].y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...