提出 #69340519
ソースコード 拡げる
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #include <cassert> #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int n, R; int L[200000]; signed main() { int i; cin >> n >> R; rep(i, n) cin >> L[i]; rep(i, n) if (L[i] == 0) break; if (i >= n) { cout << 0 << endl; return 0; } // 訪れる最も左の頂点を求める rep(i, R) if (L[i] == 0) break; int vl = i; // 訪れる最も右の頂点を求める for (i = n - 1; i >= R; i--) if (L[i] == 0) break; int vr = i + 1; int ans = 0; for (i = vl; i < vr; i++) { if (L[i] == 1) { ans += 2; } else { ans++; } } cout << ans << endl; return 0; }
提出情報
提出日時 | |
---|---|
問題 | C - Lock All Doors |
ユーザ | startcpp |
言語 | C++ 20 (gcc 12.2) |
得点 | 300 |
コード長 | 894 Byte |
結果 | AC |
実行時間 | 20 ms |
メモリ | 5276 KiB |
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 300 / 300 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
sample00.txt | AC | 1 ms | 3584 KiB |
sample01.txt | AC | 1 ms | 3536 KiB |
sample02.txt | AC | 1 ms | 3536 KiB |
testcase00.txt | AC | 12 ms | 4560 KiB |
testcase01.txt | AC | 18 ms | 5136 KiB |
testcase02.txt | AC | 16 ms | 4880 KiB |
testcase03.txt | AC | 18 ms | 5048 KiB |
testcase04.txt | AC | 3 ms | 3764 KiB |
testcase05.txt | AC | 18 ms | 5024 KiB |
testcase06.txt | AC | 14 ms | 4624 KiB |
testcase07.txt | AC | 17 ms | 5052 KiB |
testcase08.txt | AC | 8 ms | 4216 KiB |
testcase09.txt | AC | 20 ms | 5140 KiB |
testcase10.txt | AC | 15 ms | 4652 KiB |
testcase11.txt | AC | 20 ms | 5272 KiB |
testcase12.txt | AC | 2 ms | 3652 KiB |
testcase13.txt | AC | 20 ms | 5208 KiB |
testcase14.txt | AC | 17 ms | 4820 KiB |
testcase15.txt | AC | 20 ms | 5112 KiB |
testcase16.txt | AC | 18 ms | 5036 KiB |
testcase17.txt | AC | 18 ms | 5028 KiB |
testcase18.txt | AC | 1 ms | 3524 KiB |
testcase19.txt | AC | 19 ms | 5208 KiB |
testcase20.txt | AC | 11 ms | 4408 KiB |
testcase21.txt | AC | 19 ms | 5276 KiB |
testcase22.txt | AC | 17 ms | 4896 KiB |
testcase23.txt | AC | 19 ms | 5036 KiB |
testcase24.txt | AC | 16 ms | 4892 KiB |
testcase25.txt | AC | 18 ms | 5024 KiB |
testcase26.txt | AC | 17 ms | 4972 KiB |
testcase27.txt | AC | 20 ms | 5028 KiB |
testcase28.txt | AC | 18 ms | 5136 KiB |
testcase29.txt | AC | 18 ms | 5084 KiB |