結果
問題 | No.77 レンガのピラミッド |
ユーザー |
|
提出日時 | 2017-12-23 12:50:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 730 bytes |
コンパイル時間 | 1,709 ms |
コンパイル使用メモリ | 167,532 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 16:27:50 |
合計ジャッジ時間 | 2,649 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 14 WA * 2 RE * 4 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD 1000007 #define INF 100000000 using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PI; int main() { int n; int a[101] = {}; cin >> n; int sum = 0; REP(i, n) { cin >> a[i]; sum += a[i]; } int k = 1; int t = sum; while ((t -= k) >= 0) { k += 2; } int na[101] = {}; t = 0; REP(j, (k - 1) / 2) { na[j] = na[k - j - 3] = j + 1; t += na[j]; } int ans = sum; REP(j, k) { ans -= min(a[j], na[j]); } cout << ans << endl; return 0; }