結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-26 10:04:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 624 bytes |
| コンパイル時間 | 3,392 ms |
| コンパイル使用メモリ | 195,428 KB |
| 最終ジャッジ日時 | 2025-01-09 10:16:46 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 1 |
| other | AC * 15 WA * 5 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n;std::cin>>n;
std::vector<lint>a(n);
for(lint&x:a)std::cin>>x;
lint sum=std::accumulate(a.begin(),a.end(),0ll);
lint h=std::sqrt(2*sum);
if(sum<h*(h+1)/2)h--;
std::vector<lint>b(n);
for(lint i=0;i<std::min(h*2-1,n);i++){
b.at(i)=std::max(0ll,h-std::abs(i-h+1));
}
lint ans=0;
for(lint j=0;j<n;j++){
ans+=std::min(a.at(j),b.at(j));
}
std::cout<<sum-ans<<'\n';
}
ngtkana