結果
問題 | No.1007 コイン集め |
ユーザー | kotatsugame |
提出日時 | 2020-03-07 00:23:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 1,500 ms |
コード長 | 318 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 63,360 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 10:26:05 |
合計ジャッジ時間 | 1,737 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int N,K; long A[2<<17]; main() { cin>>N>>K; for(int i=0;i<N;i++)cin>>A[i]; long L=0,R=0; K--; for(int i=K-1;i>=0;i--) { L+=A[i]; if(A[i]<=1)break; } for(int i=K+1;i<N;i++) { R+=A[i]; if(A[i]<=1)break; } cout<<(A[K]==0?0:A[K]==1?L<R?R+1:L+1:L+R+A[K])<<endl; }