結果
| 問題 |
No.1007 コイン集め
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-05 00:01:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 719 bytes |
| コンパイル時間 | 2,077 ms |
| コンパイル使用メモリ | 194,796 KB |
| 最終ジャッジ日時 | 2025-02-07 21:41:11 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 8 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int N,K; cin >> N >> K; K--;
vector<ll> A(N);
rep(i,N) cin >> A[i];
if(A[K] == 0) {
cout << 0 << endl;
} else {
int L = K;
while(0 <= L && A[L] >= 2) L--;
int R = K;
while(R < N && A[R] >= 2) R++;
ll sumL = 0, sumR = 0;
for(int i = L; i <= K; i++) sumL += A[i];
for(int i = K; i <= R; i++) sumR += A[i];
if(A[K] == 1) {
cout << max(sumL, sumR) << endl;
} else {
cout << sumL + sumR - A[K] << endl;
}
}
}