提出 #4673491
ソースコード 拡げる
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[5010], b[5010], c[5010];
ll mem[5010][5010], rt, lf, n;
ll dp(int x, int y){
if(x+1==y || x==n || y==1){
return 0;
}
if(mem[x][y]!=-1)
return mem[x][y];
ll res;
int tmp=x+1;
if(b[tmp]>=y){
res=dp(x+1, y);
}
else{
res=rt+dp(x+1, y);
}
tmp=y-1;
if(c[tmp]<=x){
res=min(res, dp(x, y-1));
}
else{
res=min(res, lf+dp(x, y-1));
}
mem[x][y]=res;
return res;
}
int main(){
while(cin>>n>>lf>>rt){
ll ans=0;
int tmp;
for(int i=0; i<n; ++i){
scanf("%d",a+i);
tmp=n+1;
for(int j=0; j<i; ++j){
if(a[j]>a[i])
tmp=min(tmp, a[j]);
}
b[a[i]]=tmp;
}
for(int i=0; i<n; ++i){
tmp=0;
for(int j=n-1; j>i; --j){
if(a[j]<a[i]){
tmp=max(tmp, a[j]);
}
}
c[a[i]]=tmp;
}
memset(mem, -1, sizeof mem);
ans=dp(0,n+1);
cout<<ans<<endl;
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Rotation Sort |
| ユーザ | Zain |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 0 |
| コード長 | 1334 Byte |
| 結果 | WA |
| 実行時間 | 251 ms |
| メモリ | 196608 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:39:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",a+i);
^
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 1000 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_00.txt | AC | 49 ms | 196352 KiB |
| 0_01.txt | AC | 49 ms | 196352 KiB |
| 0_02.txt | AC | 49 ms | 196352 KiB |
| 0_03.txt | AC | 49 ms | 196352 KiB |
| 0_04.txt | AC | 49 ms | 196352 KiB |
| 1_00.txt | AC | 49 ms | 196352 KiB |
| 1_01.txt | AC | 166 ms | 196608 KiB |
| 1_02.txt | AC | 188 ms | 196608 KiB |
| 1_03.txt | WA | 251 ms | 196608 KiB |
| 1_04.txt | AC | 166 ms | 196608 KiB |
| 1_05.txt | AC | 167 ms | 196608 KiB |
| 1_06.txt | AC | 167 ms | 196608 KiB |
| 1_07.txt | AC | 166 ms | 196608 KiB |
| 1_08.txt | AC | 245 ms | 196608 KiB |
| 1_09.txt | WA | 246 ms | 196608 KiB |
| 1_10.txt | WA | 243 ms | 196608 KiB |
| 1_11.txt | WA | 243 ms | 196608 KiB |
| 1_12.txt | AC | 235 ms | 196608 KiB |
| 1_13.txt | WA | 249 ms | 196608 KiB |
| 1_14.txt | AC | 245 ms | 196608 KiB |
| 1_15.txt | WA | 248 ms | 196608 KiB |
| 1_16.txt | WA | 248 ms | 196608 KiB |
| 1_17.txt | WA | 249 ms | 196608 KiB |
| 1_18.txt | AC | 246 ms | 196608 KiB |
| 1_19.txt | WA | 246 ms | 196608 KiB |
| 1_20.txt | WA | 244 ms | 196608 KiB |
| 1_21.txt | AC | 249 ms | 196608 KiB |
| 1_22.txt | AC | 247 ms | 196608 KiB |
| 1_23.txt | WA | 247 ms | 196608 KiB |
| 1_24.txt | WA | 246 ms | 196608 KiB |
| 1_25.txt | WA | 248 ms | 196608 KiB |
| 1_26.txt | WA | 238 ms | 196608 KiB |
| 1_27.txt | AC | 246 ms | 196608 KiB |
| 1_28.txt | AC | 246 ms | 196608 KiB |
| 1_29.txt | WA | 247 ms | 196608 KiB |
| 1_30.txt | AC | 244 ms | 196608 KiB |
| 1_31.txt | WA | 240 ms | 196608 KiB |
| 1_32.txt | WA | 248 ms | 196608 KiB |
| 1_33.txt | WA | 249 ms | 196608 KiB |
| 1_34.txt | AC | 239 ms | 196608 KiB |
| 1_35.txt | WA | 245 ms | 196608 KiB |
| 1_36.txt | WA | 235 ms | 196608 KiB |
| 1_37.txt | WA | 245 ms | 196608 KiB |
| 1_38.txt | AC | 250 ms | 196608 KiB |
| 1_39.txt | WA | 249 ms | 196608 KiB |