제출 #968563

#제출 시각아이디문제언어결과실행 시간메모리
968563tsetArt Exhibition (JOI18_art)C++14
100 / 100
170 ms28848 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18 +42; signed main() { int N; scanf("%lld", &N); vector<pair<int, int>> tab; for(int iTab = 0; iTab < N; iTab++) { int A, B; scanf("%lld%lld", &A, &B); tab.push_back({A, B}); } sort(tab.begin(), tab.end()); vector<int> cumulS(N+1, 0); for(int i= 1; i<=N; i++) { cumulS[i] = cumulS[i-1] + tab[i-1].second; } vector<int> bonus(N+1); for(int i=1; i<=N; i++) { bonus[i] = max(tab[i-1].first - cumulS[i-1], bonus[i-1]); } int ans = -INF; for(int iMax=1; iMax<= N; iMax++) { ans = max(ans, cumulS[iMax] + bonus[iMax] - tab[iMax-1].first); } printf("%lld\n", ans); }

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

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