답안 #955031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955031 2024-03-29T08:23:22 Z sleepntsheep Self Study (JOI22_ho_t2) C
62 / 100
434 ms 13908 KB
#include<stdio.h>

long long max_(long long a,long long b){return a>b?a:b;}
long long min_(long long a,long long b){return a<b?a:b;}
#define N 300005

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

int ok(long long k)
{
    static long long aa[N],bb[N];
    for(int i=1;i<=n;++i)
    {
        aa[i]=min_((k+a[i]-1)/a[i],m);
        long long lf=max_(0,k-a[i]*aa[i]);
        bb[i]=(lf+b[i]-1)/b[i];
    }
    long long free=0,take=0;
    for(int i=1;i<=n;++i)
    {
        free+=m-aa[i];
        if(take+bb[i]<2e18)
            take+=bb[i];
    }
    //printf(" : %lld = %lld %lld\n",k,free,take); for(int i=1;i<=n;++i) printf("    . %lld %lld\n",aa[i],bb[i]);
    return take<=free;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i)scanf("%d",b+i),a[i]=max_(a[i],b[i]);

    long long lower=-1,upper=1e18+5;
    while(upper-lower>1)
    {
        long long mid=lower+(upper-lower)/2;
        if(ok(mid))lower=mid;
        else upper=mid;
    }
    printf("%lld",lower);
}

Compilation message

Main.c: In function 'main':
Main.c:31:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d",&n,&m);
      |     ^~~~~~~~~~~~~~~~~~~
Main.c:32:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     for(int i=1;i<=n;++i)scanf("%d",a+i);
      |                          ^~~~~~~~~~~~~~~
Main.c:33:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     for(int i=1;i<=n;++i)scanf("%d",b+i),a[i]=max_(a[i],b[i]);
      |                          ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
11 Correct 328 ms 7316 KB Output is correct
12 Correct 320 ms 7252 KB Output is correct
13 Correct 315 ms 7644 KB Output is correct
14 Correct 365 ms 7248 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 424 ms 7248 KB Output is correct
17 Correct 329 ms 13884 KB Output is correct
18 Correct 325 ms 13232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 424 ms 7248 KB Output is correct
3 Correct 329 ms 13884 KB Output is correct
4 Correct 325 ms 13232 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 166 ms 5608 KB Output is correct
14 Correct 108 ms 4952 KB Output is correct
15 Correct 81 ms 4828 KB Output is correct
16 Correct 65 ms 4696 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4528 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 7 ms 4444 KB Output is correct
23 Correct 6 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
11 Correct 328 ms 7316 KB Output is correct
12 Correct 320 ms 7252 KB Output is correct
13 Correct 315 ms 7644 KB Output is correct
14 Correct 365 ms 7248 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 166 ms 5608 KB Output is correct
24 Correct 108 ms 4952 KB Output is correct
25 Correct 81 ms 4828 KB Output is correct
26 Correct 65 ms 4696 KB Output is correct
27 Correct 2 ms 4696 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4528 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 7 ms 4444 KB Output is correct
33 Correct 6 ms 4444 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 424 ms 7248 KB Output is correct
36 Correct 329 ms 13884 KB Output is correct
37 Correct 325 ms 13232 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4516 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 6 ms 4444 KB Output is correct
46 Correct 11 ms 4740 KB Output is correct
47 Correct 2 ms 4440 KB Output is correct
48 Correct 56 ms 5468 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4524 KB Output is correct
51 Correct 6 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 160 ms 8564 KB Output is correct
56 Correct 109 ms 6400 KB Output is correct
57 Correct 121 ms 6396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 166 ms 5608 KB Output is correct
10 Correct 108 ms 4952 KB Output is correct
11 Correct 81 ms 4828 KB Output is correct
12 Correct 65 ms 4696 KB Output is correct
13 Correct 2 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4528 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 7 ms 4444 KB Output is correct
19 Correct 6 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 424 ms 7248 KB Output is correct
22 Correct 329 ms 13884 KB Output is correct
23 Correct 325 ms 13232 KB Output is correct
24 Correct 56 ms 5400 KB Output is correct
25 Correct 157 ms 8128 KB Output is correct
26 Correct 35 ms 5212 KB Output is correct
27 Correct 327 ms 13228 KB Output is correct
28 Correct 327 ms 13240 KB Output is correct
29 Correct 328 ms 13136 KB Output is correct
30 Correct 334 ms 13200 KB Output is correct
31 Correct 359 ms 13144 KB Output is correct
32 Correct 434 ms 8528 KB Output is correct
33 Incorrect 374 ms 13908 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 6 ms 4444 KB Output is correct
11 Correct 328 ms 7316 KB Output is correct
12 Correct 320 ms 7252 KB Output is correct
13 Correct 315 ms 7644 KB Output is correct
14 Correct 365 ms 7248 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 166 ms 5608 KB Output is correct
24 Correct 108 ms 4952 KB Output is correct
25 Correct 81 ms 4828 KB Output is correct
26 Correct 65 ms 4696 KB Output is correct
27 Correct 2 ms 4696 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4528 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 7 ms 4444 KB Output is correct
33 Correct 6 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4516 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 6 ms 4444 KB Output is correct
42 Correct 11 ms 4740 KB Output is correct
43 Correct 2 ms 4440 KB Output is correct
44 Correct 56 ms 5468 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4524 KB Output is correct
47 Correct 6 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 160 ms 8564 KB Output is correct
52 Correct 109 ms 6400 KB Output is correct
53 Correct 121 ms 6396 KB Output is correct
54 Correct 56 ms 5400 KB Output is correct
55 Correct 157 ms 8128 KB Output is correct
56 Correct 35 ms 5212 KB Output is correct
57 Correct 327 ms 13228 KB Output is correct
58 Correct 327 ms 13240 KB Output is correct
59 Correct 328 ms 13136 KB Output is correct
60 Correct 334 ms 13200 KB Output is correct
61 Correct 359 ms 13144 KB Output is correct
62 Correct 434 ms 8528 KB Output is correct
63 Incorrect 374 ms 13908 KB Output isn't correct
64 Halted 0 ms 0 KB -