-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
45 lines (41 loc) · 1.17 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
45 lines (41 loc) · 1.17 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
diff --git a/CodeJam/Main.cpp b/examples/2021/Round1C/A/Main.cpp
index 2150379..7e5c2b1 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2021/Round1C/A/Main.cpp
@@ -5,7 +5,7 @@
#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 COMM_TYPE ll
+#define COMM_TYPE ld
// The maintained and empty code template can be found at:
// https://github.com/demmerichs/CodeJamTemplate
@@ -1570,11 +1570,31 @@ void init(){
cin >> T;
}
+ll N, K;
+v(ll) Pi;
+
void readInput(){
+ cin >> N >> K;
+ Pi.resize(N);
+ forn(i, N) cin >> Pi[i];
+ sort(all(Pi));
}
// write to COMM_TYPE result
void calcFunction() {
+ v(ll) winners;
+ lg(Pi);
+ forn(i, N-1){
+ winners.pb((Pi[i+1]-Pi[i])/2);
+ winners.pb(Pi[i+1]-Pi[i]-1 - winners.bk);
+ }
+ winners.pb(Pi[0]-1);
+ winners.pb(K-Pi[N-1]);
+ sort(all(winners));
+ reverse(all(winners));
+ lg(winners);
+ ll total_winners = winners[0] + winners[1];
+ result = (ld) total_winners / (ld) K;
}
} // namespace task