Submission #730951

#TimeUsernameProblemLanguageResultExecution timeMemory
730951sleepntsheepArt Exhibition (JOI18_art)C++17
100 / 100
382 ms44324 KiB
#include <bits/stdc++.h> using namespace std; int main() { using ll = long long; ll n, z = 0; scanf("%lld", &n); vector<pair<ll, ll>> v(n+1); for (auto it = v.begin() + 1; it != v.end(); it++) scanf("%lld%lld", &it->first, &it->second); sort(v.begin(), v.end()); set<ll> heap; for (int i = 1; i <= n; i++) { v[i].second += v[i-1].second; z = max(z, v[i].second - v[i-1].second); if (heap.size()) z = max(z, v[i].second - v[i].first + *heap.rbegin()); heap.insert(v[i].first - v[i-1].second); heap.insert(v[i+1].first - v[i].second); } printf("%lld", z); return 0; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
art.cpp:10:61: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (auto it = v.begin() + 1; it != v.end(); it++) scanf("%lld%lld", &it->first, &it->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...