Submission #00103


ソースコード

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
#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>k){
now-=a[l];
l++;
}
//cout<<l<<' '<<r<<endl;
if(now>=k){
ans=min(ans,(r-l)+1);
}
}
cout<<ans<<endl;
}

ステータス

項目 データ
問題 0012 - しゃくとり!
ユーザー名 ei2406
投稿日時 2024-07-18 15:23:13
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 651 Byte
最大実行時間 50 ms
最大メモリ使用量 1424 KB

セット

セット 得点 Cases
1 ALL 0 / 33 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 22 ms 348 KB
1
in2.txt WA 50 ms 1416 KB
1
in3.txt WA 45 ms 1256 KB
1
in4.txt AC 36 ms 1224 KB
1
in5.txt AC 37 ms 1316 KB
1
in6.txt AC 19 ms 640 KB
1
in7.txt AC 17 ms 612 KB
1
in8.txt WA 47 ms 1352 KB
1
in9.txt AC 17 ms 552 KB
1
in10.txt AC 22 ms 440 KB
1
in11.txt WA 43 ms 1308 KB
1
in12.txt WA 36 ms 892 KB
1
in13.txt WA 43 ms 1196 KB
1
in14.txt WA 41 ms 1424 KB
1
in15.txt WA 43 ms 1268 KB
1