-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
68 lines (64 loc) · 1.86 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
68 lines (64 loc) · 1.86 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
diff --git a/CodeJam/Main.cpp b/examples/2018/Round2/B/Main.cpp
index 2150379..5e872a6 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2018/Round2/B/Main.cpp
@@ -4,7 +4,7 @@
// #define IA_MODE //remove comment on this line, to activate interactive problem mode
#define IA_ERROR_CODE -1
#define IA_COMM_LOG //add comment on this line, to deactivate the interactive communication error log
-// #define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
+#define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
#define COMM_TYPE ll
// The maintained and empty code template can be found at:
@@ -1570,11 +1570,54 @@ void init(){
cin >> T;
}
+ll R, B;
+cell cb;
+
void readInput(){
+ cin >> R >> B;
+ if(R<B){
+ ll t = R;
+ R=B;
+ B=t;
+ }
+ cb = cell(R, B);
+ llog(R, B, cb);
}
// write to COMM_TYPE result
void calcFunction() {
+ v(cell) ps;
+ forn(r, R+1){
+ forn(b, B+1){
+ ll bound_r = (b+1) * r * (r+1) /2 ;
+ ll bound_b = (r+1) * b * (b+1) / 2;
+ if(bound_r > R || bound_b > B){
+ break;
+ }
+ ps.pb(cell(b,r));
+ }
+ }
+ llog(ps);
+ v(v(v(ll))) dp(ps.sz+1, v(v(ll))(B+1, v(ll)(R+1, 0)));
+ dp[0][0][0] = 0;
+ result = 0;
+ fore(i, 1, ps.sz){
+ llog("i", i);
+ cell &cur = ps[i-1];
+ llog(cur);
+ forn(b, B+1){
+ // llog("b", b);
+ forn(r, R+1){
+ // llog("r", r);
+ if(b<cur.x || r < cur.y){
+ dp[i][b][r] = dp[i-1][b][r];
+ continue;
+ }
+ dp[i][b][r] = max(dp[i-1][b][r], 1+dp[i-1][b-cur.x][r-cur.y]);
+ }
+ }
+ }
+ result = dp[ps.sz][B][R]-1;
}
} // namespace task