結果

問題 No.1007 コイン集め
ユーザー rogi52
提出日時 2022-10-04 23:54:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 194,448 KB
最終ジャッジ日時 2025-02-07 21:36:10
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 14 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];

    ll L = 0, R = 0;
    for(int i = 0; i <= K; i++) L += A[i];
    for(int i = K; i <  N; i++) R += A[i];

    if(A[K] == 0) {
        cout << 0 << endl;
    } else if(A[K] == 1) {
        cout << max(L, R) << endl;
    } else {
        cout << L + R - A[K] << endl;
    }
}
0