Submission #204700

#TimeUsernameProblemLanguageResultExecution timeMemory
204700my99nArt Exhibition (JOI18_art)C++14
0 / 100
5 ms376 KiB
#include<bits/stdc++.h> using namespace std; pair<long long,long long> a[500100]; long long b[500100]; int main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i].first, &a[i].second); sort(a, a+n); b[0] = a[0].second; long long ans = b[0]; for (int i = 1; i < n; i++) b[i] = a[i].second - a[i].first + a[i-1].first; for (int i = 1; i < n; i++) b[i] += b[i-1], b[i] = b[i] < 0 ? 0 : b[i], ans = max(ans, b[i]); printf("%lld\n", ans); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:10:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i].first, &a[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...