Submission #272093

#TimeUsernameProblemLanguageResultExecution timeMemory
272093HalitArt Exhibition (JOI18_art)C++17
0 / 100
0 ms256 KiB
#include <bits/stdc++.h> #define max(xx,yy) (xx > yy ? xx : yy) #define min(xx,yy) (xx > yy ? yy : xx) #define all(x) x.begin(), x.end() using namespace std; int main(){ int n; scanf("%d", &n); vector< pair<long long, long long> > v; for(int i = 0;i < n;++i){ long long a,b; scanf("%lld %lld", &a, &b); v.emplace_back(a,b); } sort(all(v)); long long sum = 0, j = 0, ans = 0; for(int i = 0;i < n;++i){ sum += v[i].second; if(sum - (v[i].first - v[j].first) < 0){ j = i; sum = 0; } else{ ans = max(ans,sum - (v[i].first - v[j].first)); } } printf("%lld", ans); }

Compilation message (stderr)

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