-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
48 lines (45 loc) · 1.14 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
48 lines (45 loc) · 1.14 KB
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
diff --git a/CodeJam/Main.cpp b/examples/2021/Qualification/B/Main.cpp
index 2150379..fec72a9 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2021/Qualification/B/Main.cpp
@@ -1570,11 +1570,43 @@ void init(){
cin >> T;
}
+ll X, Y;
+str S;
+
void readInput(){
+ cin >> X >> Y;
+ cin >> S;
}
// write to COMM_TYPE result
void calcFunction() {
+ result = 0;
+ ll lastC_opt = INF/2;
+ ll lastJ_opt = INF/2;
+ if(S[0] == 'C' || S[0] == '?') lastC_opt = 0;
+ if(S[0] == 'J' || S[0] == '?') lastJ_opt = 0;
+ lg(S);
+ lg(0);
+ lg(lastC_opt);
+ lg(lastJ_opt);
+ fornn(i, 1, S.sz){
+ ll oldC = lastC_opt;
+ ll oldJ = lastJ_opt;
+ if(S[i]=='?'){
+ lastC_opt = min(oldC, oldJ + Y);
+ lastJ_opt = min(oldJ, oldC + X);
+ } else if(S[i] == 'C'){
+ lastC_opt = min(oldC, oldJ + Y);
+ lastJ_opt = INF/2;
+ } else if(S[i] == 'J'){
+ lastJ_opt = min(oldJ, oldC + X);
+ lastC_opt = INF/2;
+ }
+ lg(i);
+ lg(lastC_opt);
+ lg(lastJ_opt);
+ }
+ result = min(lastJ_opt, lastC_opt);
}
} // namespace task