結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
158b
|
| 提出日時 | 2015-06-07 21:27:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,016 bytes |
| コンパイル時間 | 686 ms |
| コンパイル使用メモリ | 72,064 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 14:35:54 |
| 合計ジャッジ時間 | 1,300 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 19 WA * 1 |
ソースコード
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
using namespace std;
#define long __int64
//#define __int64 long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vecy[4] = {0,-1,0,1};
const int Vecx[4] = {1,0,-1,0};
int main(){
int n;
int from[199] = {0};
int to[199] = {0};//1,4,9,16...
int sum = 0;
int weight;
int check;
int plus = 0;
int minus = 0;
cin >> n;
rep(i,n){
cin >> from[i];
sum += from[i];
}
check = 4;
weight = 1;
while(sum >= check){
weight += 2;
check += weight + 2;
}
for(int i=0; i<=weight/2; i++){
to[i] = i + 1;
to[weight-i-1] = i + 1;
}
for(int i=0; i<weight; i++){
//cout << to[i] << " - " << from[i] << " = " << to[i] - from[i] << endl;
if(from[i] < to[i]){
plus += to[i] - from[i];
}else if(from[i] > to[i]){
minus += from[i] - to[i];
}
}
cout << max(plus, minus) << endl;
return 0;
}
158b