結果
問題 |
No.77 レンガのピラミッド
|
ユーザー |
![]() |
提出日時 | 2020-03-26 10:01:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 2,536 ms |
コンパイル使用メモリ | 195,096 KB |
最終ジャッジ日時 | 2025-01-09 10:16:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 3 WA * 17 |
ソースコード
#include<bits/stdc++.h> using lint=long long; void cmn(lint&x,lint y){if(x>y)x=y;} 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--; cmn(h,(n+1)/2); lint w=h*2-1; std::vector<lint>b(n); for(lint i=0;i<w;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'; }