Submission #00111
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<bits/stdc++.h> #define ll long long #define endl "\n" using namespace std; int main(){ ll n,k,cheak=0; cin>>n>>k; ll a[n]; for (auto &i:a){ cin>>i; if (i>=k){ cout<< "1\n" ; return (0); } cheak+=i; } if (cheak<k){ cout<< "-1\n" ; return (0); } ll l=0,now=0,ans=10000000000000; for (ll r=0;r<n;r++){ now+=a[r]; while (now-a[l]>k && l<r){ //cout<<now-a[l]<<' '<<k<<' '; now-=a[l]; l++; } //cout<<l<<' '<<r<<endl; if (now>=k){ ans=min(ans,(r-l)); } } cout<<ans<<endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0012 - しゃくとり! |
ユーザー名 | ei2406 |
投稿日時 | 2024-07-18 15:35:55 |
言語 | C++17 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 705 Byte |
最大実行時間 | 51 ms |
最大メモリ使用量 | 1416 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 33 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | WA | 19 ms | 476 KB |
1
|
in2.txt | WA | 51 ms | 1416 KB |
1
|
in3.txt | WA | 37 ms | 1380 KB |
1
|
in4.txt | AC | 39 ms | 1216 KB |
1
|
in5.txt | WA | 33 ms | 1176 KB |
1
|
in6.txt | AC | 21 ms | 372 KB |
1
|
in7.txt | AC | 21 ms | 472 KB |
1
|
in8.txt | WA | 50 ms | 1344 KB |
1
|
in9.txt | WA | 20 ms | 540 KB |
1
|
in10.txt | AC | 21 ms | 452 KB |
1
|
in11.txt | WA | 42 ms | 1184 KB |
1
|
in12.txt | WA | 31 ms | 764 KB |
1
|
in13.txt | WA | 48 ms | 1320 KB |
1
|
in14.txt | WA | 43 ms | 1296 KB |
1
|
in15.txt | WA | 36 ms | 1140 KB |
1
|