結果
問題 | No.77 レンガのピラミッド |
ユーザー |
![]() |
提出日時 | 2017-10-13 18:37:45 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 80,324 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 11:28:13 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; int main() { int N; cin >> N; vector<int> A(N); int s = 0; for ( int i = 0; i < N; i++ ) { cin >> A[i]; s += A[i]; } int ans = INT_MAX; for ( int i = 1; ((i+1)/2)*((i+1)/2) <= s; i += 2 ) { int x = 0; for ( int j = 0; j < i; j++ ) { int y = (i+1)/2 - abs( i/2 - j ); x += max( 0, y - ( (j < N) ? A[j] : 0 ) ); } // cout << i << " " << x << endl; x += s-(((i+1)/2)*((i+1)/2)); // cout << i << " " << x << endl; ans = min( ans, x ); } cout << ans << endl; return 0; }