forked from shunr/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccc13s2.cpp
More file actions
43 lines (41 loc) · 738 Bytes
/
ccc13s2.cpp
File metadata and controls
43 lines (41 loc) · 738 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
43
#include <stdio.h>
#include <algorithm>
int main() {
int n;
int *memes;
scanf("%d", &n);
int x;
scanf("%d", &x);
memes = new int [x];
for (int i = 0; i < x; i++) {
scanf("%d", &memes[i]);
}
int s = 0;
int d = 0;
bool rekt = false;
int crossed = std::min(4, x);
for (int i = 0; i < crossed; i++) {
s += memes[i];
if (s > n) {
printf("%d", d);
rekt = true;
break;
}
d += 1;
}
if (!rekt) {
for (int i = crossed; i < x; i++) {
s += memes[i];
s -= memes[i-4];
if (s > n) {
printf("%d", d);
rekt = true;
break;
}
d += 1;
}
}
if (!rekt) {
printf("%d", d);
}
}