Submission #1308005

#TimeUsernameProblemLanguageResultExecution timeMemory
1308005dimitris71Art Exhibition (JOI18_art)C++17
100 / 100
134 ms8716 KiB
#include <cstdio> #include <algorithm> #include <vector> #include <utility> using namespace std; vector < pair < long long, int > > X; int main() { int N; long long res = 0, best = 1e18, sum = 0; scanf("%d", &N); for (int i=0; i<N; i++) { long long a; int b; scanf("%lld%d", &a, &b); X.push_back(make_pair(a, b)); } sort(X.begin(), X.end()); for (int i=0; i<N; i++) { best = min(best, sum - X[i].first); sum += X[i].second; res = max(res, sum - X[i].first - best); } printf("%lld\n", res); }

Compilation message (stderr)

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