結果
| 問題 |
No.1007 コイン集め
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2020-03-06 22:04:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 679 bytes |
| コンパイル時間 | 678 ms |
| コンパイル使用メモリ | 76,036 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-14 07:06:09 |
| 合計ジャッジ時間 | 1,620 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 3 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
k--;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (a[k] == 0) {
cout << 0 << endl;
exit(0);
}
ll r = a[k];
for (int i = k + 1; i < n; i++) {
r += a[i];
if (a[i] < 2) break;
}
for (int i = k - 1; i >= 0; i--) {
r += a[i];
if (a[i] < 2) break;
}
cout << r << endl;
return 0;
}
merom686