| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 300463 | daniel920712 | Carnival Tickets (IOI20_tickets) | C++14 | 877 ms | 84028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <algorithm>
using namespace std;
struct A
{
int where;
int con;
}tt[1505];
vector < vector < int > > answer;
vector < int > row;
vector< vector<int> > all;
vector < int > how;
bool have[1505][1505];
bool use[1505]={0};
long long DP[1505][1505];
int a[1505];
int b[1505];
int N,M;
long long F(int here,int con)
{
if(con>N/2) return -1e18;
if(here==N&&con!=N/2) return -1e18;
if(here==N) return 0;
if(have[here][con]) return DP[here][con];
have[here][con]=1;
DP[here][con]=max(F(here+1,con+1)+all[here][M-1],F(here+1,con)-all[here][0]);
return DP[here][con];
}
void F2(int here,int con)
{
if(here==N) return;
//printf("%d %d\n",F(here+1,con+1)+all[here][M-1],F(here+1,con)-all[here][0]);
if(F(here+1,con+1)+all[here][M-1]>F(here+1,con)-all[here][0])
{
//printf("aa\n");
F2(here+1,con+1);
answer[here][M-1]=0;
}
else
{
F2(here+1,con);
answer[here][0]=0;
}
}
long long find_maximum(int k,vector< vector<int> > x)
{
all=x;
N=x.size();
M=x[0].size();
int i,j,l,t,ok,now;
long long ans=0;
for(i=0;i<M;i++) row.push_back(-1);
for(i=0;i<N;i++)
{
answer.push_back(row);
for(j=0;j<M;j++) how.push_back(x[i][j]);
}
if(k==1)
{
ans=F(0,0);
F2(0,0);
}
else
{
for(i=0;i<N*M/2;i++) ans-=how[i];
for(i=N*M/2;i<N*M;i++) ans+=how[i];
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
{
if(x[i][j]<how[N*M/2]) a[i]++;
if(x[i][j]>how[N*M/2-1]) b[i]++;
}
}
for(i=0;i<N;i++)
{
if(use[i]) continue;
for(j=i+1;j<N;j++)
{
if(b[i]+b[j]>N||a[i]+a[j]>N) continue;
use[j]=1;
for(l=0;l<M;l++) answer[i][l]=l;
for(l=0;l<M;l++) answer[j][l]=M-l-1;
break;
}
}
}
allocate_tickets(answer);
return 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
