Submission #947662

# Submission time Handle Problem Language Result Execution time Memory
947662 2024-03-16T17:53:53 Z veljko Self Study (JOI22_ho_t2) C++17
54 / 100
212 ms 11600 KB
/*****from dust I have come, dust I will be*****/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define forn(i,n) for(int i=0;i<n;i++)
int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int ceil_div(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
 
const int MOD = 1000000007;
//const int MOD = 998244353;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
 
/*
int k = A.order_of_key(p[i].second);
A.erase(A.find_by_order(k));
erase element from pbds multiset
*/

bool ok(vector<int>&a, int n, int v, int target){
    forn(i,n){
        int x = ceil_div(target, a[i]);
        //cout <<x<<'\n';
        v -= x;
        if (v < 0) return false;
    }
    return (v >= 0);
}
 
int binary(vector<int>&a, int n, int v){
    int l = 0, r = 5 * 1e18;
    int ans = 0;
    while (l <= r){
        int mid = (l + r) / 2;
        if (ok(a, n, v, mid)){
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    return ans;
}
 
void solve(){
    int n, m; cin >> n >> m;
    vector<int>a(n); for (auto &t : a) cin >> t;
    vector<int>b(n); for (auto &t : b) cin >> t;
    
    cout << binary(a, n, n*m)<<'\n';
    
}
 
 
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 

 
    int t = 1; //cin >>t;
    for (int i=1;i<=t;i++){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 41 ms 2788 KB Output is correct
10 Correct 28 ms 1880 KB Output is correct
11 Correct 26 ms 1568 KB Output is correct
12 Correct 20 ms 1416 KB Output is correct
13 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 25 ms 4952 KB Output is correct
22 Correct 83 ms 11416 KB Output is correct
23 Correct 80 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 41 ms 2788 KB Output is correct
10 Correct 28 ms 1880 KB Output is correct
11 Correct 26 ms 1568 KB Output is correct
12 Correct 20 ms 1416 KB Output is correct
13 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 25 ms 4952 KB Output is correct
22 Correct 83 ms 11416 KB Output is correct
23 Correct 80 ms 10832 KB Output is correct
24 Correct 26 ms 2092 KB Output is correct
25 Correct 66 ms 5088 KB Output is correct
26 Correct 11 ms 1372 KB Output is correct
27 Correct 89 ms 10768 KB Output is correct
28 Correct 91 ms 10896 KB Output is correct
29 Correct 87 ms 10836 KB Output is correct
30 Correct 107 ms 10960 KB Output is correct
31 Correct 182 ms 10736 KB Output is correct
32 Correct 105 ms 6316 KB Output is correct
33 Correct 212 ms 11600 KB Output is correct
34 Correct 106 ms 6316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -