# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1101785 | kasdo | Art Exhibition (JOI18_art) | C++14 | 1 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for(int i=1; i<=n; i++)
{
p[i] = p[i - 1] + a[i].second;
}
int ans = 0;
for(int i=1; i<=n; i++)
{
int cur = 0;
for(int j=i; j<=n; j++) cur = max(cur, (p[j] - a[j].first));
// ai = mn, aj = mx;
ans = max(ans, cur - (p[i - 1] - a[i].first));
// ans = max(ans, cur - (p[i - 1] - a[i].first));
}
cout<<ans<<endl;
}
signed main ()
{
speed
// freopen("feast.in", "r", stdin);
// freopen("feast.out", "w", stdout);
int _ = 1;
// cin>>_;
while(_--) 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... |