# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
66829 | ege_eksi | Art Exhibition (JOI18_art) | C++14 | 2 ms | 252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<algorithm>
using namespace std;
bool mycomp(pair<long long int,int> x , pair<long long int,int> y)
{
if(x.first < y.first)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int n;
scanf("%d",&n);
pair<long long int,int> *a = new pair<long long int,int>[n];
for(int i = 0 ; i < n ; i++)
{
scanf("%lli %d" , &a[i].first , &a[i].second);
}
sort(a , a+n , mycomp);
pair<long long int , long int> *d = new pair<long long int , long int>[n];
int cnt = 0;
d[0] = a[0];
for(int i = 1 ; i < n ; i++)
{
if(d[cnt].first != a[i].first)
{
cnt++;
d[cnt] = a[i];
}
else
{
d[cnt].second += a[i].second;
}
}
long long int *prefix = new long long int[cnt];
prefix[0] = d[0].second;
for(int i = 1 ; i <= cnt ; i++)
{
prefix[i] = prefix[i-1] + d[i].second;
}
long long int ans = INT_MIN;
for(int i = 0 ; i <= cnt ; i++)
{
for(int j = i+1 ; j <= cnt ; j++)
{
long long int value;
if(i == 0)
{
value = prefix[j];
}
else
{
value = prefix[j] - prefix[i-1];
}
ans = max(ans , value - (d[j].first - d[i].first));
}
}
printf("%d",ans);
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... |