Submission #170274

#TimeUsernameProblemLanguageResultExecution timeMemory
170274AkashiArt Exhibition (JOI18_art)C++14
0 / 100
2 ms376 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; int j = 1; for(int i = 2; i <= n ; ++i){ Sum = Sum + a[i].y - a[i].x + a[i - 1].x; while(j < i && Sum < Sum - a[j].y - a[j].x + a[j + 1].x){ Sum = Sum - a[j].y - a[j].x; ++j; Sum += a[j].x; } Sol = max(Sol, Sum); } 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...