結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-26 09:59:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 852 bytes |
| コンパイル時間 | 2,211 ms |
| コンパイル使用メモリ | 197,768 KB |
| 最終ジャッジ日時 | 2025-01-09 10:16:22 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 2 WA * 18 |
ソースコード
#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=std::numeric_limits<lint>::max();
for(lint i=w;i<=n;i++){
lint now=0;
for(lint j=0;j<n;j++){
now+=std::min(a.at(j),b.at(j));
}
cmn(ans,now);
std::rotate(b.begin(),b.end()-1,b.end());
}
std::cout<<sum-ans<<'\n';
}
ngtkana