結果
| 問題 |
No.484 収穫
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-29 22:58:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 813 bytes |
| コンパイル時間 | 1,675 ms |
| コンパイル使用メモリ | 162,240 KB |
| 実行使用メモリ | 35,072 KB |
| 最終ジャッジ日時 | 2025-01-29 22:58:43 |
| 合計ジャッジ時間 | 3,029 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | freopen("apple.in","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:33:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | freopen("apple.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
int a[2005];
int f[2005][2005];
void read(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
}
void work(){
memset(f,0x3f,sizeof(f));
f[1][n]=f[n][1]=0;
for(int l=n;l>1;l--){
for(int i=1;i+l-1<=n;i++){
int j=i+l-1;
f[i][j]=min(f[i][j],f[j][i]+(j-i-1));
f[j][i]=min(f[j][i],f[i][j]+(j-i-1));
f[i+1][j]=min(f[i+1][j],max(f[i][j],a[i])+1);
f[j-1][i]=min(f[j-1][i],max(f[j][i],a[j])+1);
}
}
int ans=f[0][0];
for(int i=1;i<=n;i++){
ans=min(ans,max(f[i][i],a[i]));
}
cout<<ans<<endl;
}
signed main(){
freopen("apple.in","r",stdin);
freopen("apple.out","w",stdout);
read();
work();
return 0;
}
vjudge1