-
Notifications
You must be signed in to change notification settings - Fork 1
/
2017 S1.cpp
57 lines (35 loc) · 1.05 KB
/
2017 S1.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
51
52
53
54
55
56
57
/*
2017 S1 - Sum Game
Difficulty: Very Easy
Very simple problem. Take in inputs, store them in vectors.
Loop through the vectors, add each vector's sum to total runs of the corresponding team.
Compare the teams, if they're equal, update the maximum possible day.
*/
#include <iostream>
#include <vector>
int main(){
int N;
std::cin >> N;
int K = 0; //0 by default since if no value of K where both teams have equal runs, you should output 0
int swifts = 0, semaphores = 0; //Total runs of each team
std::vector<int> swiftsRuns (N);
std::vector<int> semaphoresRuns (N);
for (int i = 0; i < N; i++){
std::cin >> swiftsRuns[i];
}
for (int i = 0; i < N; i++){
std::cin >> semaphoresRuns[i];
}
//For each day
for (int i = 0; i < N; i++){
//Update sums
swifts += swiftsRuns[i];
semaphores += semaphoresRuns[i];
//Check if equal
if (swifts == semaphores){
K = i + 1; //Update max day
}
}
std::cout << K; //Output day
return 0;
}