Submission #1086637

# Submission time Handle Problem Language Result Execution time Memory
1086637 2024-09-11T07:39:11 Z dwuy Self Study (JOI22_ho_t2) C++14
100 / 100
103 ms 11576 KB
/**         - dwuy -

      />    フ
      |  _  _|
      /`ミ _x ノ
     /      |
    /   ヽ   ?
 / ̄|   | | |
 | ( ̄ヽ__ヽ_)_)
 \二つ

**/
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) (int)((s).size())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 300005;

int n, m;
int a[MX];
int b[MX];

int32_t main(){
    fastIO;
    //file(TASK);

    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=n; i++) cin >> b[i];
    for(int i=1; i<=n; i++) a[i] = max(a[i], b[i]);
 
    int res = 0;
    for(int lo=1, hi=OO; lo<=hi;){
        int mid = (lo + hi)>>1;
        int fund = 0;
        for(int i=1; i<=n; i++){
            int d = mid/a[i] + !!(mid%a[i]);
            if(d <= m) fund += m - d;
            else{
                int f = mid - a[i]*m;
                fund -= f/b[i] + !!(f%b[i]);
            }
            if(m*n + fund < 0) break;
        }
        if(fund >= 0) res = mid, lo = mid + 1;
        else hi = mid - 1;
    }
    cout << res;

    return 0;
}

/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 67 ms 10824 KB Output is correct
12 Correct 69 ms 10832 KB Output is correct
13 Correct 70 ms 8880 KB Output is correct
14 Correct 49 ms 8940 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 25 ms 6336 KB Output is correct
17 Correct 83 ms 11576 KB Output is correct
18 Correct 65 ms 10836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 25 ms 6336 KB Output is correct
3 Correct 83 ms 11576 KB Output is correct
4 Correct 65 ms 10836 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 35 ms 5460 KB Output is correct
14 Correct 23 ms 3932 KB Output is correct
15 Correct 16 ms 2908 KB Output is correct
16 Correct 15 ms 2576 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 67 ms 10824 KB Output is correct
12 Correct 69 ms 10832 KB Output is correct
13 Correct 70 ms 8880 KB Output is correct
14 Correct 49 ms 8940 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 35 ms 5460 KB Output is correct
24 Correct 23 ms 3932 KB Output is correct
25 Correct 16 ms 2908 KB Output is correct
26 Correct 15 ms 2576 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 25 ms 6336 KB Output is correct
36 Correct 83 ms 11576 KB Output is correct
37 Correct 65 ms 10836 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 464 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 3 ms 780 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 14 ms 2272 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 632 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 37 ms 5604 KB Output is correct
56 Correct 24 ms 3164 KB Output is correct
57 Correct 17 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 35 ms 5460 KB Output is correct
10 Correct 23 ms 3932 KB Output is correct
11 Correct 16 ms 2908 KB Output is correct
12 Correct 15 ms 2576 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 25 ms 6336 KB Output is correct
22 Correct 83 ms 11576 KB Output is correct
23 Correct 65 ms 10836 KB Output is correct
24 Correct 15 ms 2088 KB Output is correct
25 Correct 41 ms 5144 KB Output is correct
26 Correct 9 ms 1372 KB Output is correct
27 Correct 68 ms 10684 KB Output is correct
28 Correct 80 ms 10860 KB Output is correct
29 Correct 81 ms 10736 KB Output is correct
30 Correct 82 ms 10836 KB Output is correct
31 Correct 90 ms 10836 KB Output is correct
32 Correct 58 ms 6236 KB Output is correct
33 Correct 89 ms 11344 KB Output is correct
34 Correct 63 ms 6216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 67 ms 10824 KB Output is correct
12 Correct 69 ms 10832 KB Output is correct
13 Correct 70 ms 8880 KB Output is correct
14 Correct 49 ms 8940 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 35 ms 5460 KB Output is correct
24 Correct 23 ms 3932 KB Output is correct
25 Correct 16 ms 2908 KB Output is correct
26 Correct 15 ms 2576 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 464 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 3 ms 780 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 14 ms 2272 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 632 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 37 ms 5604 KB Output is correct
52 Correct 24 ms 3164 KB Output is correct
53 Correct 17 ms 3052 KB Output is correct
54 Correct 15 ms 2088 KB Output is correct
55 Correct 41 ms 5144 KB Output is correct
56 Correct 9 ms 1372 KB Output is correct
57 Correct 68 ms 10684 KB Output is correct
58 Correct 80 ms 10860 KB Output is correct
59 Correct 81 ms 10736 KB Output is correct
60 Correct 82 ms 10836 KB Output is correct
61 Correct 90 ms 10836 KB Output is correct
62 Correct 58 ms 6236 KB Output is correct
63 Correct 89 ms 11344 KB Output is correct
64 Correct 63 ms 6216 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 25 ms 6336 KB Output is correct
67 Correct 83 ms 11576 KB Output is correct
68 Correct 65 ms 10836 KB Output is correct
69 Correct 10 ms 1372 KB Output is correct
70 Correct 3 ms 716 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 14 ms 1984 KB Output is correct
73 Correct 4 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 83 ms 10928 KB Output is correct
76 Correct 78 ms 10832 KB Output is correct
77 Correct 87 ms 10836 KB Output is correct
78 Correct 92 ms 10736 KB Output is correct
79 Correct 102 ms 10928 KB Output is correct
80 Correct 103 ms 10844 KB Output is correct
81 Correct 76 ms 8784 KB Output is correct
82 Correct 76 ms 8784 KB Output is correct