-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmau_carater.cpp
More file actions
42 lines (38 loc) · 775 Bytes
/
mau_carater.cpp
File metadata and controls
42 lines (38 loc) · 775 Bytes
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
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, s, soma = 0, i, j, k, aux = 2, inter, ajud1, ajud2;
cin >> n >> s;
int vet[n];
for (i = 0; i < n; i++)
scanf("%d", &vet[i]);
for (i = 0; i < n; i++)
{
if (vet[i] >= s)
{
printf("1");
return 0;
}
}
for (k = 1; k < n; k++)
{
ajud1 = n - aux;
for (i = 0; i <= ajud1; i++)
{
ajud2 = i + aux;
for (j = i; j < ajud2; j++)
{
soma += vet[j];
}
if (soma >= s)
{
printf("%d", aux);
return 0;
}
soma = 0;
}
aux++;
}
printf("-1");
}