# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
211944 | Harry464 | Art Exhibition (JOI18_art) | C++14 | 5 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
vector <pair <ll,ll> > a(n);
for (int i = 0; i < n; i++)
cin >> a[i].first >> a[i].second;
sort(a.begin(),a.end());
ll max_so_far = -100000000000000001, max_ending_here = 0, start =0, end = 0, s=0;
for (int i=0; i< n; i++ )
{
max_ending_here += a[i].second;
if (i > 0)
max_ending_here -= a[i].first - a[i-1].first;
if (max_so_far < max_ending_here)
{
max_so_far = max_ending_here;
start = s;
end = i;
}
if (max_ending_here < 0)
{
max_ending_here = 0;
s = i + 1;
}
}
cout << max_so_far << endl;
}
컴파일 시 표준 에러 (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... |