Submission #00041


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
int cnt=0;
cin >> n;
stack<int> go;
int c,p,m;
cin >> c;
p=c;
m=1;
for(int i=1;i<n;i++){
cin >> c;
if(i%2==0){
if(c==p){//同じ
m++;
}else{
go.push(m);
m = 1;
p = c;
}
}else{
if(c==p){//奇数で同じ
}else{
if(!go.empty()){
m += go.top();
go.pop();
}
p = c;
}
m++;
}
}
if(c==0){
cnt += m;
go.pop();
}
while(!go.empty()){
cnt += go.top();
go.pop();
if(go.empty())break;
go.pop();
}
cout << cnt << endl;
}

ステータス

項目 データ
問題 0001 - 碁石ならべ
ユーザー名 ei1435
投稿日時 2016-02-09 18:01:25
言語 C++11
状態 Runtime Error
得点 90
ソースコード長 649 Byte
最大実行時間 43 ms
最大メモリ使用量 672 KB

セット

セット 得点 Cases
1 INPUT1 10 / 10 *in01
2 INPUT2 10 / 10 *in02
3 INPUT3 10 / 10 *in03
4 INPUT4 10 / 10 *in04
5 INPUT5 0 / 10 *in05
6 INPUT6 10 / 10 *in06
7 INPUT7 10 / 10 *in07
8 INPUT8 10 / 10 *in08
9 INPUT9 10 / 10 *in09
10 INPUT10 10 / 10 *in10

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2008-ho-t1-in01 AC 21 ms 476 KB
1
2008-ho-t1-in02 AC 14 ms 448 KB
2
2008-ho-t1-in03 AC 13 ms 424 KB
3
2008-ho-t1-in04 AC 14 ms 396 KB
4
2008-ho-t1-in05 RE 43 ms 496 KB
5
2008-ho-t1-in06 AC 24 ms 596 KB
6
2008-ho-t1-in07 AC 26 ms 572 KB
7
2008-ho-t1-in08 AC 24 ms 672 KB
8
2008-ho-t1-in09 AC 23 ms 520 KB
9
2008-ho-t1-in10 AC 22 ms 496 KB
10