-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1860.cpp
More file actions
33 lines (26 loc) · 700 Bytes
/
1860.cpp
File metadata and controls
33 lines (26 loc) · 700 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
#include<iostream>
#include<vector>
std::vector<int> memLeak(int memory1, int memory2) {
int time = 1;
while(true) {
if(memory2 > memory1) {
if(time > memory2) break;
memory2 -= time;
} else {
if(time > memory1) break;
memory1 -= time;
} ++time;
// std::cout << "mem1: " << memory1 << " mem2: " << memory2 << "\n";
}
std::vector<int> result = {time, memory1, memory2};
return result;
}
int main() {
int memory1 = 9;
int memory2 = 6;
std::vector<int> vec = memLeak(memory1, memory2);
for(const auto& i : vec) {
std::cout << i << " ";
}
std::cin.get();
}