답안 #703373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703373 2023-02-27T07:38:10 Z niter Self Study (JOI22_ho_t2) C++14
0 / 100
551 ms 4980 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<long long,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n";
using namespace std;

long long a[300050], b[300050], as[300050];

/*ostream& operator<<(ostream &os, pii XXX){
    cout << "[" << XXX.ff << ", " << XXX.ss << "]";
}
void db(){
    cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
    cout << XXX;  db(YYY...);
}*/

int main(){
    long long n, m, all;
    cin >> n >> m;
    all = n * m;
    loop(i,0,n) cin >> a[i];
    loop(i,0,n) cin >> b[i];
    long long l = 1, r = (long long)(1e18), mid;
    long long cost, tmp_pay, classes;
    while(l != r){
        mid = (l + r + 1) >> 1;
        classes = 0;
        loop(i,0,n){
            cost = mid;
            if(b[i] >= a[i]){
                classes += ((cost-1) / b[i] + 1);
            }
            else{
                tmp_pay = min(((cost-1) / a[i] + 1), m);
                classes += tmp_pay;
                cost -= tmp_pay * a[i];
                if(cost <= 0) continue;

                tmp_pay = ((cost-1) / b[i] + 1);
                classes += tmp_pay;
            }
            //db(i, ' ', classes);
        }
        if(classes > all){
            r = mid - 1;
        }
        else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}
/*
3 3
19 4 5
2 6 2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 345 ms 4904 KB Output is correct
12 Correct 347 ms 4980 KB Output is correct
13 Correct 263 ms 4864 KB Output is correct
14 Incorrect 551 ms 4960 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 167 ms 2552 KB Output is correct
10 Correct 110 ms 1764 KB Output is correct
11 Correct 78 ms 1456 KB Output is correct
12 Correct 65 ms 1228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 345 ms 4904 KB Output is correct
12 Correct 347 ms 4980 KB Output is correct
13 Correct 263 ms 4864 KB Output is correct
14 Incorrect 551 ms 4960 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 167 ms 2552 KB Output is correct
10 Correct 110 ms 1764 KB Output is correct
11 Correct 78 ms 1456 KB Output is correct
12 Correct 65 ms 1228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 345 ms 4904 KB Output is correct
12 Correct 347 ms 4980 KB Output is correct
13 Correct 263 ms 4864 KB Output is correct
14 Incorrect 551 ms 4960 KB Output isn't correct
15 Halted 0 ms 0 KB -