結果
問題 | No.77 レンガのピラミッド |
ユーザー |
![]() |
提出日時 | 2015-07-25 01:44:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 407 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 66,732 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-16 04:23:09 |
合計ジャッジ時間 | 1,310 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include<iostream> #include<vector> #include<cmath> #include<algorithm> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); int sum = 0; for (int i = 0; i<n; i++){ cin >> a[i]; sum += a[i]; } sum = (int)sqrt(sum); int ans = 0; int now = 0; for (int i = 0; i<n; i++){ if (i<sum) now++; else if (now>0) now--; ans += max(0, a[i] - now); } cout << ans << endl; return 0; }