# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
66733 | MrTEK | Art Exhibition (JOI18_art) | C++14 | 338 ms | 12424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'
typedef long long int ll;
const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 5e5 + 5;
const int M = 1e4 + 5;
const int SQ = 350;
const int MOD = 998244353;
typedef pair <int,int> pii;
pair <ll ,ll> ar[N];
ll pre[N],ans;
int n,opt = 1;
int main() {
scanf("%d",&n);
for (int i = 1 ; i <= n ; i++) scanf("%lld %lld",&ar[i].fi,&ar[i].sc);
sort(ar + 1,ar + n + 1);
for (int i = 1 ; i <= n ; i++) pre[i] = pre[i - 1] + ar[i].sc;
ans = ar[1].sc;
for (int i = 2 ; i <= n ; i++) {
if (ar[i].fi > ar[opt].fi + pre[i - 1] - pre[opt - 1]) opt = i;
ans = max(ans,-ar[i].fi + ar[opt].fi + pre[i] - pre[opt - 1]);
}
printf("%lld\n",ans);
}
컴파일 시 표준 에러 (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... |