이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++17 -D_GLIBCXX_DEBUG art.cpp -oart && ./art " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fv(i,v) f(i,sz(v))
struct S{ int a,b; };
main(){
ios::sync_with_stdio(0),cin.tie(0);
int n;
cin>>n;
vc<S> art(n);
f(i,n) cin>>art[i].a>>art[i].b;
sort(all(art),[](S x,S y){ return x.a>y.a; });
vc<int> p(n+1);
f(i,n) p[i+1]=p[i]+art[i].b;
int best=0;
int low=art[0].a;
f(i,n+1){
if(i) best=max(best,p[i]+art[i-1].a-low);
if(i<n) low=min(low,p[i]+art[i].a);
}
cout<<best<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main(){
| ^~~~
# | 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... |