Submission #1086635

# Submission time Handle Problem Language Result Execution time Memory
1086635 2024-09-11T07:37:05 Z dwuy Self Study (JOI22_ho_t2) C++14
10 / 100
66 ms 11344 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 + 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 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 66 ms 10928 KB Output is correct
12 Correct 61 ms 10836 KB Output is correct
13 Correct 43 ms 8784 KB Output is correct
14 Correct 45 ms 8784 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 22 ms 6244 KB Output is correct
17 Correct 56 ms 11344 KB Output is correct
18 Correct 55 ms 10836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 22 ms 6244 KB Output is correct
3 Correct 56 ms 11344 KB Output is correct
4 Correct 55 ms 10836 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 460 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 66 ms 10928 KB Output is correct
12 Correct 61 ms 10836 KB Output is correct
13 Correct 43 ms 8784 KB Output is correct
14 Correct 45 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 460 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 66 ms 10928 KB Output is correct
12 Correct 61 ms 10836 KB Output is correct
13 Correct 43 ms 8784 KB Output is correct
14 Correct 45 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 460 KB Output isn't correct
17 Halted 0 ms 0 KB -