結果
問題 | No.77 レンガのピラミッド |
ユーザー | alpha_virginis |
提出日時 | 2016-02-29 00:36:30 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 882 bytes |
コンパイル時間 | 501 ms |
コンパイル使用メモリ | 67,052 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-24 18:57:35 |
合計ジャッジ時間 | 1,235 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 1 ms
4,348 KB |
testcase_05 | AC | 1 ms
4,348 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
4,348 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
4,348 KB |
testcase_10 | AC | 1 ms
4,348 KB |
testcase_11 | AC | 1 ms
4,348 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
4,348 KB |
testcase_16 | AC | 1 ms
4,348 KB |
testcase_17 | AC | 1 ms
4,348 KB |
testcase_18 | WA | - |
testcase_19 | AC | 1 ms
4,348 KB |
testcase_20 | AC | 2 ms
4,348 KB |
testcase_21 | AC | 1 ms
4,348 KB |
testcase_22 | AC | 1 ms
4,348 KB |
testcase_23 | AC | 2 ms
4,348 KB |
testcase_24 | AC | 1 ms
4,348 KB |
ソースコード
#include <cstring> #include <iostream> #include <vector> #include <string> #include <map> #include <queue> #include <algorithm> #include <stack> int N; int A[128]; int total; int diff(int h) { if( total < h * h ) return 100000; int target[128]; for(int i = 0; i < h; ++i) { target[i] = i + 1; } for(int i = h; i < 2 * h - 1; ++i) { target[i] = 2 * h - i - 1; } int res = 0; for(int i = 0; i < 2 * h - 1; ++i) { res += std::max(0, (A[i] - target[i])); } for(int i = 2 * h - 1; i < 128; ++i) { res += A[i]; } if( res < 0 ) res = 100000; //printf("%d : %d\n", h, res); return res; } int main() { std::cin >> N; for(int i = 0; i < N; ++i) std::cin >> A[i]; for(int i = 0; i < N; ++i) total += A[i]; int res = 100000; for(int i = 1; i < 50; ++i) { res = std::min(res, diff(i)); } printf("%d\n", res); return 0; }