제출 #47013

#제출 시각아이디문제언어결과실행 시간메모리
47013leejseoArt Exhibition (JOI18_art)C++17
100 / 100
326 ms20436 KiB
#include <stdio.h> #include <utility> #include <algorithm> #include <vector> using namespace std; #define MAXN 500002 typedef long long lld; typedef pair<lld, lld> pll; lld S[MAXN], X[MAXN], Y[MAXN], ans; vector<pll> U; int N; int main(void){ scanf("%d", &N); lld a, b; for (int i=0; i<N; i++){ scanf("%lld%lld", &a, &b); U.push_back(make_pair(a, b)); } sort(U.begin(), U.end()); for (int i=0; i<N; i++){ S[i+1] = S[i] + U[i].second; } Y[0] = -(U[0].first); for (int i=1; i<=N; i++){ X[i] = S[i] - U[i-1].first; if (i != N) Y[i] = min(Y[i-1], S[i]-U[i].first); } for (int i=0; i<N; i++) ans = max(ans, X[i+1]-Y[i]); printf("%lld", ans); }

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

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