# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1178753 | vyaduct | Art Exhibition (JOI18_art) | C++20 | 1 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void setIo(string in="", string out=""){
if (!in.empty() && !out.empty()){
freopen(in.c_str(), "r", stdin);
freopen(out.c_str(), "w", stdout);
}
ios::sync_with_stdio(false);
cin.tie(0);
}
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define vt vector
#define pb push_back
#define F first
#define S second
void solve(){
int n; cin>>n;
vt<pair<ll,ll>> A(n);
for (int i=0;i<n;i++){
cin>>A[i].F>>A[i].S;
}
sort(all(A));
vt<ll> pref(n+1);
for (int i=0;i<n;i++) pref[i+1] = pref[i] + A[i].S;
ll best=-1e18;
for (int i=0;i<n;i++){
for (int j=i+1;j<n;j++){
ll Amax = A[j].F;
ll Amin = A[i].F;
ll S = pref[j+1] - pref[i];
best = max(best, S - (Amax - Amin));
}
}
cout << best << endl;
}
int main() {
setIo();
int tt=1;
// cin>>tt;
while(tt--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |