Submission #744348

#TimeUsernameProblemLanguageResultExecution timeMemory
744348MONArt Exhibition (JOI18_art)C++14
100 / 100
205 ms20752 KiB
#include <cstdio> #include <algorithm> using namespace std; int N; pair<long long, int> X[505050]; int main() { scanf("%d", &N); for (int i = 0; i < N; ++i) { long long A; int B; scanf("%lld%d", &A, &B); X[i] = make_pair(A, B); } sort(X, X + N); long long ret = 0, acc = 0, lo = 0; for (int i = 0; i < N; ++i) { lo = min(lo, acc - X[i].first); acc += X[i].second; ret = max(ret, acc - X[i].first - lo); } printf("%lld\n", ret); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
art.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%lld%d", &A, &B);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...