-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1769.cpp
More file actions
44 lines (35 loc) · 908 Bytes
/
1769.cpp
File metadata and controls
44 lines (35 loc) · 908 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
44
#include<iostream>
#include<vector>
std::vector<int> minOperations(std::string boxes) {
std::vector<int> operations(boxes.size());
int count = 0;
for(int i = 0; i < operations.size(); ++i) {
for(int j = i; j < boxes.size() - 1; ++j) {
++count;
if(boxes[j + 1] == '1') {
operations[i] += count;
}
}
count = 0;
}
for(int k = operations.size() - 1; k >= 0; --k) {
for(int l = k; l > 0; --l) {
++count;
if(boxes[l - 1] == '1') {
operations[k] += count;
}
}
count = 0;
}
return operations;
}
int main() {
std::string boxes = "001011";
std::vector<int> operations = minOperations(boxes);
/*std::cout << operations[0];*/
for(int i : operations)
{
std::cout << i << " ";
}
std::cin.get();
}