9751 | 2024-03-06 11:56:39 | UnluckY | Hőmérsékletek | cpp17 | Accepted 100/100 | 46ms | 6908 KiB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, e; cin >> n >> e;
vector<int> v;
for (int i = 0; i < n; i++){
int a; cin >> a; v.push_back(a);
}
int b = -1, j = -1, curr = 0;
bool vanerossz = false;
int maxi = 0;
pair<int, int> maxis = {0, 0};
while (b < n-1 && j < n-1){
while (curr <= e && !vanerossz && j < n-1){
j++;
if (v[j] < 15 || v[j] > 25) curr++;
if (v[j] < 10 || v[j] > 30) vanerossz = true;
if (j-b > maxi && curr <= e && !vanerossz && j < n){
maxi = j-b;
maxis = {b, j};
}
}
b++;
if (v[b] < 15 || v[b] > 25) curr--;
if (v[b] < 10 || v[b] > 30) vanerossz = false;
}
if (maxi == 0){
cout << -1 << endl;
return 0;
}
cout << maxis.first+2 << " " << maxis.second+1 << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 7/7 | ||||||
3 | Accepted | 3ms | 2308 KiB | ||||
4 | Accepted | 3ms | 2324 KiB | ||||
5 | Accepted | 3ms | 2332 KiB | ||||
6 | Accepted | 4ms | 2672 KiB | ||||
7 | Accepted | 24ms | 3660 KiB | ||||
8 | Accepted | 46ms | 4428 KiB | ||||
9 | Accepted | 3ms | 2616 KiB | ||||
subtask3 | 14/14 | ||||||
10 | Accepted | 3ms | 2816 KiB | ||||
11 | Accepted | 2ms | 2892 KiB | ||||
12 | Accepted | 3ms | 2892 KiB | ||||
13 | Accepted | 3ms | 3092 KiB | ||||
14 | Accepted | 3ms | 3096 KiB | ||||
15 | Accepted | 3ms | 3188 KiB | ||||
16 | Accepted | 3ms | 3192 KiB | ||||
subtask4 | 38/38 | ||||||
17 | Accepted | 2ms | 3184 KiB | ||||
18 | Accepted | 3ms | 3208 KiB | ||||
19 | Accepted | 3ms | 3440 KiB | ||||
20 | Accepted | 4ms | 3864 KiB | ||||
21 | Accepted | 4ms | 4136 KiB | ||||
22 | Accepted | 23ms | 5308 KiB | ||||
23 | Accepted | 25ms | 5332 KiB | ||||
24 | Accepted | 3ms | 4300 KiB | ||||
subtask5 | 41/41 | ||||||
25 | Accepted | 24ms | 5656 KiB | ||||
26 | Accepted | 46ms | 6556 KiB | ||||
27 | Accepted | 46ms | 6640 KiB | ||||
28 | Accepted | 46ms | 6592 KiB | ||||
29 | Accepted | 21ms | 5816 KiB | ||||
30 | Accepted | 45ms | 6696 KiB | ||||
31 | Accepted | 45ms | 6700 KiB | ||||
32 | Accepted | 46ms | 6768 KiB | ||||
33 | Accepted | 21ms | 5792 KiB | ||||
34 | Accepted | 21ms | 5800 KiB | ||||
35 | Accepted | 21ms | 5908 KiB | ||||
36 | Accepted | 3ms | 4676 KiB | ||||
37 | Accepted | 3ms | 4780 KiB | ||||
38 | Accepted | 45ms | 6828 KiB | ||||
39 | Accepted | 43ms | 6908 KiB |