답안 #548686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548686 2022-04-14T09:12:46 Z cpp219 Self Study (JOI22_ho_t2) C++17
25 / 100
1000 ms 11460 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 3e5 + 9;
const ll inf = 1e16 + 7;

ll n,m,a[N],b[N];

bool chk(ll tar){
    ll spare = 0;
    for (ll i = 1;i <= n;i++){
        ll mx = max(a[i],b[i]);
        if (m*mx > tar) spare += m - ceil((ld)tar/mx);
        else spare -= ceil((ld)(tar - mx*m)/b[i]);
    }
    return (spare >= 0);
}

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>n>>m;
    for (ll i = 1;i <= n;i++) cin>>a[i];
    for (ll i = 1;i <= n;i++) cin>>b[i];
    ll l,mid,h; l = 1; h = inf; //debug(chk(18));
    while(l <= h){
        mid = (l + h)/2;
        if (chk(mid)) l = mid + 1;
        else h = mid - 1;
    }
    cout<<h;
}
/// be confident

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 560 KB Output is correct
11 Execution timed out 1048 ms 10808 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 530 ms 5636 KB Output is correct
10 Correct 351 ms 3812 KB Output is correct
11 Correct 282 ms 2948 KB Output is correct
12 Correct 253 ms 2420 KB Output is correct
13 Correct 5 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 17 ms 496 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 170 ms 6180 KB Output is correct
22 Correct 785 ms 11460 KB Output is correct
23 Correct 954 ms 10812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 560 KB Output is correct
11 Execution timed out 1048 ms 10808 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 530 ms 5636 KB Output is correct
10 Correct 351 ms 3812 KB Output is correct
11 Correct 282 ms 2948 KB Output is correct
12 Correct 253 ms 2420 KB Output is correct
13 Correct 5 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 17 ms 496 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 170 ms 6180 KB Output is correct
22 Correct 785 ms 11460 KB Output is correct
23 Correct 954 ms 10812 KB Output is correct
24 Correct 274 ms 1940 KB Output is correct
25 Correct 620 ms 5024 KB Output is correct
26 Correct 142 ms 1364 KB Output is correct
27 Correct 980 ms 10808 KB Output is correct
28 Correct 940 ms 10808 KB Output is correct
29 Execution timed out 1041 ms 10732 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 23 ms 560 KB Output is correct
11 Execution timed out 1048 ms 10808 KB Time limit exceeded
12 Halted 0 ms 0 KB -