Submission #00099


ソースコード

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
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int main(){
ll n,k;
bool ok = 0;
cin >> n >> k;
ll a[n];
for(auto &i:a)cin >> i;
ll l=0,sum=0,mn=500000;
for(ll r=0;r<n;r++){
sum += a[r];
while(sum - a[l]>=k&&r>=l){
sum -= a[l];
l++;
}
if(sum >= k){
mn = min(mn,r-l+1);
ok = 1;
}
}
if(ok){
cout << mn << endl;
}else cout << -1 << endl;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 24 ms 472 KB
1
in2.txt AC 52 ms 1304 KB
1
in3.txt AC 44 ms 1268 KB
1
in4.txt AC 34 ms 1368 KB
1
in5.txt AC 34 ms 1336 KB
1
in6.txt AC 21 ms 528 KB
1
in7.txt AC 20 ms 500 KB
1
in8.txt WA 62 ms 1364 KB
1
in9.txt AC 22 ms 556 KB
1
in10.txt AC 23 ms 448 KB
1
in11.txt AC 43 ms 1068 KB
1
in12.txt AC 33 ms 644 KB
1
in13.txt AC 47 ms 1208 KB
1
in14.txt AC 51 ms 1180 KB
1
in15.txt AC 36 ms 1152 KB
1