제출 #1101742

#제출 시각아이디문제언어결과실행 시간메모리
1101742kasdoArt Exhibition (JOI18_art)C++14
50 / 100
1055 ms32444 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define speed cin.tie (0) -> sync_with_stdio (0);ios_base::sync_with_stdio(false);cin.tie(0); void solve() { int n; cin>>n; pair<int, int> a[n + 5]; for(int i=1; i<=n; i++) cin>>a[i].first>>a[i].second; sort(a+1, a+n+1); int s[n + 5] = {}, mx[n + 5] = {}, p[n + 5] = {}; p[1] = a[1].second; int sum = 0; for(int i=1; i<=n; i++) { p[i] = p[i - 1] + a[i].second; s[i] = p[i] - a[i].first; } for(int i=n; i>0; i--) mx[i] = max(mx[i + 1], s[i]); int ans = 0; for(int i=1; i<=n; i++) { // cout<<-a[i].first + mx[i] - p[i]<<endl; // cout<<s[i]<<endl; for(int j=i; j<=n; j++) { ans = max(ans, p[j] - a[j].first - p[i - 1] + a[i].first); } // ans = max(ans, -a[i].first + mx[i] - p[i]); } cout<<ans<<endl; //4232545716 } signed main () { speed // freopen("feast.in", "r", stdin); // freopen("feast.out", "w", stdout); int _ = 1; // cin>>_; while(_--) solve(); return 0; }

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

art.cpp: In function 'void solve()':
art.cpp:16:9: warning: unused variable 'sum' [-Wunused-variable]
   16 |     int sum = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...