結果

問題 No.1007 コイン集め
ユーザー ateate
提出日時 2020-07-08 22:26:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 341 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 75,308 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 07:14:44
合計ジャッジ時間 2,329 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 44 ms
6,940 KB
testcase_13 AC 44 ms
6,940 KB
testcase_14 AC 44 ms
6,944 KB
testcase_15 AC 17 ms
6,940 KB
testcase_16 AC 18 ms
6,944 KB
testcase_17 AC 18 ms
6,940 KB
testcase_18 AC 48 ms
6,944 KB
testcase_19 AC 47 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 47 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
signed main(){
  int n,k;
  std::cin>>n>>k;
  k--;
  std::vector<int> a(n);
  for(auto& ai:a)std::cin>>ai;
  int l=k,r=k;
  while(l>0){
    if(a[l]<=1)break;
    l--;
  }
  while(r<n){
    if(a[r]<=1)break;
    r++;
  }
  int64_t ans = 0;
  for(int i=l;i<=r;++i)ans+=a[i];
  std::cout<< ans <<std::endl;
}
0