Submission #00096


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define ll long long
#define ptn(v) next_permutation(v.begin(), v.end())
#define fixed(v) fixed << setprecision(v)
#define total(n) (n * (n + 1) / 2)
#define lcm(a, b) ((a) * (b) / __gcd(a, b))
// 最小値=max_element(v.begin(),v.end());
// 最大値=min_element(v.begin(),v.end());
using namespace std;
int main(){
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
bool jadge=1;
int cnt=0;
//内側
while(jadge){
int max=0,pls=-1;
for(int i=0;i<n;i++){
if(max<v[i]&&(i!=0&&i!=n-1)){
max=v[i];
pls=i;
}
}
if(pls==-1){
jadge=0;
}
if(jadge){
if(v[pls-1]<v[pls+1]){
v[pls]--;
v[pls+1]--;
cnt+=2;
} else {
v[pls]--;
v[pls-1]--;
cnt+=2;
}
}
}
// 外側
jadge=1;
while(jadge){
int max=0,pls=-1;
for(int i=0;i<n;i++){
if(max<v[i]&&(i==0||i==n-1)){
max=v[i];
pls=i;
}
}
if(pls==-1){
jadge=0;
}
if(jadge){
if(pls==0){
if(v[1]>0){
v[0]--;
v[1]--;
cnt+=2;
} else {
v[0]--;
cnt++;
}
} else if(pls==n-1){
if(v[n-2]>0){
v[n-1]--;
v[n-2]--;
cnt+=2;
} else {
v[n-1]--;
cnt++;
}
}
}
}
cout<<cnt<<endl;
return (0);
}

ステータス

項目 データ
問題 0006 - パンケーキの焼き上がり
ユーザー名 ei2134
投稿日時 2022-07-19 17:16:07
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 1946 Byte
最大実行時間 31 ms
最大メモリ使用量 800 KB

セット

セット 得点 Cases
1 ALL 0 / 6 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 31 ms 476 KB
1
in02.txt AC 19 ms 444 KB
1
in03.txt AC 23 ms 672 KB
1
in04.txt AC 20 ms 512 KB
1
in05.txt AC 23 ms 484 KB
1
in06.txt WA 23 ms 576 KB
1
in07.txt AC 15 ms 548 KB
1
in08.txt AC 18 ms 524 KB
1
in09.txt AC 28 ms 620 KB
1
in10.txt AC 21 ms 588 KB
1
in11.txt AC 21 ms 560 KB
1
in12.txt AC 15 ms 532 KB
1
in13.txt AC 22 ms 508 KB
1
in14.txt AC 18 ms 476 KB
1
in15.txt AC 20 ms 700 KB
1
in16.txt AC 17 ms 676 KB
1
in17.txt AC 20 ms 648 KB
1
in18.txt AC 18 ms 616 KB
1
in19.txt WA 16 ms 592 KB
1
in20.txt AC 19 ms 688 KB
1
in21.txt AC 24 ms 528 KB
1
in22.txt AC 28 ms 624 KB
1
in23.txt AC 24 ms 576 KB
1
in24.txt AC 30 ms 660 KB
1
in25.txt AC 29 ms 608 KB
1
in26.txt AC 22 ms 432 KB
1
in27.txt AC 20 ms 644 KB
1
in28.txt AC 27 ms 720 KB
1
in29.txt AC 26 ms 800 KB
1
in30.txt AC 20 ms 760 KB
1