結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2015-06-20 12:32:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,137 bytes |
| コンパイル時間 | 644 ms |
| コンパイル使用メモリ | 82,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 15:10:10 |
| 合計ジャッジ時間 | 1,444 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 3 WA * 17 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
int main(){
int N, tmp;
vector<int> v;
cin >> N;
int allv = 0;
rep(i,N){
cin >> tmp;
v.push_back(tmp);
allv += tmp;
}
int ret = 100000000;
for(int i=1; i<=N; i+=2){
int x = 1;
vector<int> w;
int allw = 0;
rep(j,i){
w.push_back(x);
allw += x;
if(j<i/2) x++;
else x--;
}
if(allw>allv) break;
rep(st,N-w.size()+1){
int sum = 0;
rep(j,st) sum += v[j];
rep(j,w.size()){
if(v[st+j] > w[j]) sum += v[st+j]-w[j];
}
REP(j,st+w.size(),N) sum += v[j];
ret = min(ret, sum);
}
}
cout << ret << endl;
return 0;
}
どらら