Submission #724797

# Submission time Handle Problem Language Result Execution time Memory
724797 2023-04-16T02:56:56 Z Cookie Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 10728 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const ll mod = 1e9 + 7;
const int mxn = 3e5 + 5, mxv = 1e6;
ll n, m;
ll a[mxn + 1], b[mxn + 1];
bool ck(ll mid){
    ll need = 0;
    forr(i, 0, n){
        ll have = max(a[i], b[i]) * m;
        need += min(m, (ll)ceil((ld)(mid) / (ld)(max(a[i], b[i]))));
        
        if(mid > have){
            need += ceil((ld)(mid - have) / (ld)(b[i]));
        }
        
    }
    
    return(need <= n * m);
}
signed main(){
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    forr(i, 0, n){
        cin >> a[i];
    }
    forr(i, 0, n)cin >> b[i];
    ll l = 1, r= 1e18, ans = 0;
    while(l <= r){
        ll mid = (l + r) >> 1;
        if(ck(mid)){
            ans = mid; l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    cout << ans;
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 21 ms 468 KB Output is correct
11 Execution timed out 1087 ms 10728 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 775 ms 4848 KB Output is correct
10 Correct 477 ms 3832 KB Output is correct
11 Correct 349 ms 2948 KB Output is correct
12 Correct 302 ms 2540 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Incorrect 44 ms 416 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 21 ms 468 KB Output is correct
11 Execution timed out 1087 ms 10728 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 775 ms 4848 KB Output is correct
10 Correct 477 ms 3832 KB Output is correct
11 Correct 349 ms 2948 KB Output is correct
12 Correct 302 ms 2540 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Incorrect 44 ms 416 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 21 ms 468 KB Output is correct
11 Execution timed out 1087 ms 10728 KB Time limit exceeded
12 Halted 0 ms 0 KB -