結果
| 問題 | No.1007 コイン集め |
| コンテスト | |
| ユーザー |
ei13337
|
| 提出日時 | 2020-03-06 23:16:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 425 bytes |
| コンパイル時間 | 1,472 ms |
| コンパイル使用メモリ | 167,504 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 09:45:14 |
| 合計ジャッジ時間 | 2,654 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 11 WA * 8 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
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;
return 0;
}
long long ans = a[k];
int pos = k;
while(pos && a[pos - 1]) {
pos--;
ans += a[pos];
}
pos = k;
while(pos < n - 1 && a[pos + 1]) {
pos++;
ans += a[pos];
}
cout << ans << endl;
}
ei13337