Submission #730949

#TimeUsernameProblemLanguageResultExecution timeMemory
730949sleepntsheepArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, z = 0; scanf("%d", &n); vector<pair<int, int>> v(n+1); for (auto it = v.begin() + 1; it != v.end(); it++) scanf("%d%d", &it->first, &it->second); sort(v.begin(), v.end()); set<int> 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("%d", z); return 0; }

Compilation message (stderr)

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