結果
問題 | No.77 レンガのピラミッド |
ユーザー |
![]() |
提出日時 | 2022-01-12 22:44:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 422 bytes |
コンパイル時間 | 1,937 ms |
コンパイル使用メモリ | 192,592 KB |
最終ジャッジ日時 | 2025-01-27 10:39:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n,a[110],tot,ans=1e8,t[210]; int main(){ cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; tot+=a[i]; } for(int i=1;i*i<=tot;i++){ for(int j=1;j<=i;++j) t[j]=j; for(int j=i+1,k=i-1;k>0;++j,--k) t[j]=k; int s=0; for(int j=1;j<=n;++j) if(a[j]>t[j]) s+=a[j]-t[j]; ans=min(ans,s); } cout<<ans<<endl; return 0; }