제출 #931923

#제출 시각아이디문제언어결과실행 시간메모리
931923lovrotArt Exhibition (JOI18_art)C++17
100 / 100
175 ms23048 KiB
#include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> #include <set> #include <queue> #include <deque> #include <vector> #include <random> #include <chrono> #define X first #define Y second #define PB push_back #define EB emplace_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MOD = 1e9 + 7; // 998 244 353; const int N = 5e5 + 10; const ll OO = 1e18; int n, I[N]; ll A[N], B[N]; ll prf, xam = -OO, ans; int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%lld%lld\n", A + i, B + i); I[i] = i; } sort(I, I + n, [](int a, int b) { return A[a] < A[b]; }); for(int i = 0; i < n; ++i) { xam = max(xam, -prf + A[I[i]]); prf += B[I[i]]; ans = max(ans, prf - A[I[i]] + xam); } printf("%lld\n", ans); return 0; }

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

art.cpp: In function 'int main()':
art.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
art.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%lld%lld\n", A + i, B + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...