제출 #542056

#제출 시각아이디문제언어결과실행 시간메모리
542056lunchboxArt Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long ans, mx; int n; scanf("%d", &n); vector<pair<long long, long long>> a(n); for (auto &[x, y] : a) scanf("%lld%lld", &x, &y); sort(a.begin(), a.end()); for (int i = 0; i + 1 < n; i++) a[i + 1].second += a[i].second; mx = 0, ans = -0x3f3f3f3f3f3f3f3f; for (int i = 0; i < n; i++) { ans = max(ans, a[i].second - a[i].first + mx); mx = max(mx, a[i].first - (i == 0 ? 0 : a[i - 1].second)); } printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  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", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...