-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathlua.cpp
50 lines (35 loc) · 723 Bytes
/
lua.cpp
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
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main() {
int n1, n2, test=1;
cin >> n1 >> n2;
while (n1 + n2 != 0) {
vector<int> v;
for (int i = 0; i < n1; i++) {
int temp;
cin >> temp;
v.push_back(temp);
}
int total = 0;
for (int i = 0; i < n2; i++)
total += v[i];
int max = (total / n2);
int min = (total / n2);
for (int i = n2; i < n1; i++) {
total -= v[i-n2];
total += v[i];
int media = total / n2;
if (media > max) max = media;
if (media < min) min = media;
}
cout << "Teste " << test << endl;
cout << min << " " << max << endl << endl;
test++;
cin >> n1 >> n2;
}
return 0;
}