Submission #00085


ソースコード

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
#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]){
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++;
}
} else {
if(v[pls-1]<v[pls+1]){
v[pls]--;
v[pls+1]--;
cnt+=2;
} else {
v[pls]--;
v[pls-1]--;
cnt+=2;
}
}
}
}
cout<<cnt<<endl;
return (0);
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 21 ms 604 KB
1
in02.txt AC 25 ms 448 KB
1
in03.txt AC 17 ms 544 KB
1
in04.txt WA 19 ms 516 KB
1
in05.txt AC 23 ms 364 KB
1
in06.txt WA 20 ms 592 KB
1
in07.txt AC 24 ms 564 KB
1
in08.txt AC 24 ms 536 KB
1
in09.txt WA 20 ms 500 KB
1
in10.txt AC 18 ms 476 KB
1
in11.txt AC 23 ms 444 KB
1
in12.txt AC 18 ms 412 KB
1
in13.txt AC 20 ms 520 KB
1
in14.txt AC 19 ms 484 KB
1
in15.txt AC 22 ms 580 KB
1
in16.txt AC 23 ms 424 KB
1
in17.txt AC 20 ms 400 KB
1
in18.txt WA 19 ms 504 KB
1
in19.txt WA 22 ms 728 KB
1
in20.txt AC 19 ms 564 KB
1
in21.txt WA 17 ms 532 KB
1
in22.txt AC 42 ms 628 KB
1
in23.txt AC 21 ms 580 KB
1
in24.txt AC 51 ms 528 KB
1
in25.txt AC 38 ms 612 KB
1
in26.txt AC 20 ms 564 KB
1
in27.txt AC 21 ms 640 KB
1
in28.txt AC 22 ms 588 KB
1
in29.txt AC 20 ms 672 KB
1
in30.txt AC 25 ms 620 KB
1