結果
問題 | No.77 レンガのピラミッド |
ユーザー | tsukio |
提出日時 | 2016-03-07 15:17:31 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,379 bytes |
コンパイル時間 | 595 ms |
コンパイル使用メモリ | 64,812 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 15:10:44 |
合計ジャッジ時間 | 1,279 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,944 KB |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { vector<int*> pyramid_blocks; int index = 0; for (int count_block = 1; count_block < 10000; count_block += 2) { int *blocks = new int[2]; if (count_block == 1) { blocks[0] = 1; blocks[1] = 1; } else { blocks[0] = pyramid_blocks[index - 1][0] + count_block; blocks[1] = count_block; } pyramid_blocks.push_back(blocks); index++; } int n; cin >> n; int blocks[101]; int count_all_block = 0; for (int i = 0; i < n; i++) { string count_block; cin >> count_block; blocks[i] = stoi(count_block); count_all_block += blocks[i]; } int pyramid_row_index = 0; for (int i = 0; i < pyramid_blocks.size(); i++) { if (pyramid_blocks[i][0] <= count_all_block) { pyramid_row_index = i; } else { break; } } int max_width = pyramid_blocks[pyramid_row_index][1]; int* pyramid_data = new int[max_width]; for (int i = 0; i < max_width; i++) { pyramid_data[i] = 0; } int count_row = 0; for (int y = pyramid_row_index; y >= 0; y--) { int* blocks = pyramid_blocks[y]; for (int x = 0; x < blocks[1]; x++) { pyramid_data[x + count_row]++; } count_row++; } for (int i = 0; i < min(max_width, n); i++) { count_all_block -= min(pyramid_data[i], blocks[i]); } cout << count_all_block << endl; return 0; }