Submission #00098
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int x, y; int last = -1; while ( n != 0 ) { int ans = 0; vector< int >a(n); vector< int >b(n); x = 0; y = 0; for ( int i = 0; i < n; i++ ) { cin>>a[i]; } for ( int i = 0; i < n; i++ ) { cin>>b[i]; } for ( int i = 0; i < n; i++ ) { x += a[i]; y += b[i]; if ( x < y && last != 1 ) { last = 1; ans++; } else if ( y < x && last != 2 ) { last = 2; ans++; } } if ( ans - 1 < 0 ) { ans = 1; } cout<<ans - 1<<endl; cin>>n; last = -1; } } |
ステータス
項目 | データ |
---|---|
問題 | 0006 - 追い抜き |
ユーザー名 | ei2437 |
投稿日時 | 2025-03-28 12:08:02 |
言語 | C++ |
状態 | Accepted |
得点 | 20 |
ソースコード長 | 749 Byte |
最大実行時間 | 31 ms |
最大メモリ使用量 | 492 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 20 / 20 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
B1 | AC | 31 ms | 476 KB |
1
|
B2 | AC | 29 ms | 444 KB |
1
|
B3 | AC | 29 ms | 404 KB |
1
|
B4 | AC | 30 ms | 492 KB |
1
|