結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
kongarishisyamo
|
| 提出日時 | 2016-02-29 02:40:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 728 bytes |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 56,020 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 12:38:13 |
| 合計ジャッジ時間 | 1,591 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 14 WA * 6 |
ソースコード
#include<iostream>
using namespace std;
#define NMAX 100
int main(){
int N;
int A[NMAX+1]={0};
int sum[NMAX*2+1]={0};
int suma=0;
int ans=-1;
int locd,loca;
cin>>N;
for(int i=1;i<=200;i+=2){
int c=1;
for(int j=0;j<i;j++){
sum[i]+=c;
if(i/2+1>j+1) c++;
else c--;
}
}
for(int i=1;i<=N;i++){
cin>>A[i];
suma+=A[i];
}
for(int i=1;;i+=2){
if(sum[i]>suma) break;
locd=0;
loca=0;
int c=1;
for(int j=1;j<=i;j++){
if(c>A[j]) loca+=c-A[j];
else if(c<A[j]) locd+=A[j]-c;
if(i/2+1>j) c++;
else c--;
}
for(int j=i+1;j<=N;j++){
locd+=A[j];
}
/*cout<<i<<","<<loca<<","<<locd<<endl;*/
if(loca>locd) continue;
if(ans==-1||locd<ans) ans=locd;
}
cout<<ans<<endl;
}
kongarishisyamo