제출 #64046

#제출 시각아이디문제언어결과실행 시간메모리
64046patrikpavic2Art Exhibition (JOI18_art)C++17
50 / 100
370 ms34188 KiB
#include <cstdio> #include <vector> #include <set> #include <algorithm> #define X first #define Y second using namespace std; typedef long long ll; typedef pair < ll , ll > pii; const int N = 1e5 + 500; vector < pii > v; set < pii > s; ll sol = 0, pref[N]; int n; int main(){ scanf("%d", &n); for(int i = 0;i<n;i++){ ll x, y;scanf("%lld%lld", &x, &y); v.push_back({x, y}); } sort(v.rbegin(), v.rend()); for(int i = 0;i<n;i++){ pref[i] = (i ? pref[i - 1] : 0) + v[i].Y; } for(int i = 0;i<n;i++){ s.insert({pref[i] + v[i].X, i}); } for(int i = 0;i<n;i++){ sol = max(sol, (s.rbegin()->X) - (i ? pref[i - 1] : 0) - v[i].X); s.erase({pref[i] + v[i].X, i}); } printf("%lld\n", sol); return 0; }

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

art.cpp: In function 'int main()':
art.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
art.cpp:24:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ll x, y;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...