Submission #330733

#TimeUsernameProblemLanguageResultExecution timeMemory
330733M_WArt Exhibition (JOI18_art)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; #define ii pair<long long, long long> ii aw[500500]; long long val[500500]; int main(){ int N; scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%lld %lld", &aw[i].first, &aw[i].second); sort(aw, aw + N); val[0] = aw[0].second; for(int i = 1; i < N; i++) val[i] = aw[i].second - (aw[i].first - aw[i - 1].first); long long curmax = 0, maxmax = INT_MIN; for(int i = 0; i < N; i++){ curmax = max(curmax + val[i], 0 * 1ll); maxmax = max(maxmax, curmax); } printf("%lld", maxmax); }

Compilation message (stderr)

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