-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
53 lines (48 loc) · 1.01 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
53 lines (48 loc) · 1.01 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
diff --git a/CodeJam/Main.cpp b/examples/2020/KS_C/C/Main.cpp
index 2150379..cadea53 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2020/KS_C/C/Main.cpp
@@ -1566,15 +1566,48 @@ using namespace std;
namespace task {
+const ll offset = 10000000;
+v(ll) sqrs;
+v(ll) cumsumc;
+
void init(){
cin >> T;
+ ll c = 0;
+ while(true){
+ sqrs.pb(c*c);
+ if(sqrs.bk>=offset) break;
+ c++;
+ }
}
+int N;
+v(int) Ai;
+
void readInput(){
+ cin >> N;
+ Ai.resize(N);
+ forn(i, N) cin >> Ai[i];
}
// write to COMM_TYPE result
void calcFunction() {
+ result = 0;
+
+ cumsumc.assign(2*offset+1, 0);
+ cumsumc[0+offset]=1;
+ lg(cumsumc[0]);
+ lg(cumsumc[2*offset]);
+ int sum = 0;
+ forn(i, N){
+ sum += Ai[i];
+ lg(sum);
+ foreach(sq, sqrs){
+ if(offset+sum-sq <0)break;
+ if(offset+sum-sq>=2*offset+1) continue;
+ result += cumsumc[offset+sum-sq];
+ }
+ cumsumc[offset+sum]++;
+ }
}
} // namespace task