結果
問題 |
No.77 レンガのピラミッド
|
ユーザー |
![]() |
提出日時 | 2014-11-26 00:15:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,310 bytes |
コンパイル時間 | 725 ms |
コンパイル使用メモリ | 82,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 02:51:22 |
合計ジャッジ時間 | 1,733 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 3 WA * 17 |
ソースコード
#include <vector> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <algorithm> #include <functional> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cctype> #include <string> #include <cstring> using namespace std; typedef long long ll; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int total = 0; for (int i = 0; i < n; i++) total += a[i]; int ans = 1000000000; int cnt = 0; for (int i = 1; i <= n; i++) { if (i%2 == 0) continue; cnt++; if (total < cnt*cnt) continue; for (int bias = 0; bias <= n-i; bias++) { int k = 0, s = 0; for (int j = 0; j < i/2; j++) { if (a[j+bias] > j+1) { k += a[j+bias]-(j+1); }else { s += j+1-a[j+bias]; } } for (int j = i/2, l = i/2; j < i; j++,l--) { if (a[j+bias] > l+1) { k += a[j+bias]-(l+1); }else { s += l+1-a[j+bias]; } } for (int j = 0; j < bias; j++) k += a[j]; for (int j = i+bias; j < n; j++) k += a[j]; ans = min(k, ans); // cout << sum << " " << i << endl; } } cout << ans << endl; }