File tree 2 files changed +60
-0
lines changed 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ inline int64_t binary_search (
4
+ std::function<bool (int64_t )> const & predicate,
5
+ int64_t ng,
6
+ int64_t ok
7
+ ) {
8
+ assert (!predicate (ng) && predicate (ok));
9
+ while (abs (ok - ng) > 1 ) {
10
+ auto m = (ok + ng) / 2 ;
11
+ if (predicate (m)) ok = m;
12
+ else ng = m;
13
+ }
14
+ return ok;
15
+ }
16
+
17
+ using namespace std ;
18
+ using ll = int64_t ;
19
+ using ff = long double ;
20
+
21
+ int N, L, K;
22
+ vector<int > A;
23
+ vector<int > B;
24
+
25
+ bool pass (int T) {
26
+ int c = 0 ;
27
+ int x = 0 ;
28
+ for (auto b : B) {
29
+ x += b;
30
+ if (x >= T) {
31
+ ++c;
32
+ x = 0 ;
33
+ }
34
+ }
35
+ return c >= K + 1 ;
36
+ }
37
+
38
+ int solve () {
39
+ B.push_back (A[0 ]);
40
+ for (int i = 1 ; i < N; ++i) {
41
+ B.push_back (A[i] - A[i-1 ]);
42
+ }
43
+ B.push_back (L - A[N-1 ]);
44
+
45
+ int ok = 1 , ng = 1e9 +1 ;
46
+ return binary_search (pass, ng, ok);
47
+ }
48
+
49
+ int main () {
50
+ ios_base::sync_with_stdio (false );
51
+ cin.tie (0 ); cout.tie (0 );
52
+
53
+ cin >> N >> L >> K;
54
+ A.assign (N, 0 );
55
+ for (auto &ai : A) cin >> ai;
56
+ cout << solve () << endl;
57
+
58
+ return 0 ;
59
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ We can use this technique in many problems. It's a pretty powerful technique.
27
27
- [ Widespread] ( https://atcoder.jp/contests/abc063/tasks/arc075_b )
28
28
- [ 射撃王] ( https://atcoder.jp/contests/abc023/tasks/abc023_d )
29
29
- [ 壁抜け] ( https://atcoder.jp/contests/abc020/tasks/abc020_c )
30
+ - [ 001 - Yokan Party] ( https://atcoder.jp/contests/typical90/tasks/typical90_a )
30
31
31
32
32
33
## Dice
You can’t perform that action at this time.
0 commit comments