답안 #955036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955036 2024-03-29T08:25:52 Z sleepntsheep Self Study (JOI22_ho_t2) C
62 / 100
311 ms 7680 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;
        if((k+a[i]-1)/a[i]<=m) lf=0;
        else lf=k-m*1ll*a[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];

    for(int i=1;i<=n;++i)
    {
        take+=bb[i];
        if(take>free)return 0;
    }

    return 1;
}

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=1e16+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:34:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d%d",&n,&m);
      |     ^~~~~~~~~~~~~~~~~~~
Main.c:35:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     for(int i=1;i<=n;++i)scanf("%d",a+i);
      |                          ^~~~~~~~~~~~~~~
Main.c:36:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     for(int i=1;i<=n;++i)scanf("%d",b+i),a[i]=max_(a[i],b[i]);
      |                          ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 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 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4544 KB Output is correct
11 Correct 231 ms 7436 KB Output is correct
12 Correct 232 ms 7680 KB Output is correct
13 Correct 221 ms 7252 KB Output is correct
14 Correct 254 ms 7372 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 311 ms 7432 KB Output is correct
17 Correct 228 ms 7248 KB Output is correct
18 Correct 231 ms 7436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 311 ms 7432 KB Output is correct
3 Correct 228 ms 7248 KB Output is correct
4 Correct 231 ms 7436 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 4440 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 119 ms 5712 KB Output is correct
14 Correct 78 ms 4956 KB Output is correct
15 Correct 58 ms 4828 KB Output is correct
16 Correct 48 ms 4740 KB Output is correct
17 Correct 2 ms 4440 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 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 6 ms 4444 KB Output is correct
23 Correct 4 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 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 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4544 KB Output is correct
11 Correct 231 ms 7436 KB Output is correct
12 Correct 232 ms 7680 KB Output is correct
13 Correct 221 ms 7252 KB Output is correct
14 Correct 254 ms 7372 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4440 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 119 ms 5712 KB Output is correct
24 Correct 78 ms 4956 KB Output is correct
25 Correct 58 ms 4828 KB Output is correct
26 Correct 48 ms 4740 KB Output is correct
27 Correct 2 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 6 ms 4444 KB Output is correct
33 Correct 4 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 311 ms 7432 KB Output is correct
36 Correct 228 ms 7248 KB Output is correct
37 Correct 231 ms 7436 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 4440 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 4440 KB Output is correct
45 Correct 5 ms 4444 KB Output is correct
46 Correct 8 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 41 ms 4716 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 5 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 118 ms 5696 KB Output is correct
56 Correct 75 ms 4956 KB Output is correct
57 Correct 87 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4440 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 119 ms 5712 KB Output is correct
10 Correct 78 ms 4956 KB Output is correct
11 Correct 58 ms 4828 KB Output is correct
12 Correct 48 ms 4740 KB Output is correct
13 Correct 2 ms 4440 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 6 ms 4444 KB Output is correct
19 Correct 4 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 311 ms 7432 KB Output is correct
22 Correct 228 ms 7248 KB Output is correct
23 Correct 231 ms 7436 KB Output is correct
24 Correct 42 ms 4696 KB Output is correct
25 Correct 118 ms 5528 KB Output is correct
26 Correct 26 ms 4444 KB Output is correct
27 Correct 232 ms 7248 KB Output is correct
28 Correct 236 ms 7316 KB Output is correct
29 Correct 237 ms 7252 KB Output is correct
30 Correct 250 ms 7408 KB Output is correct
31 Incorrect 276 ms 7432 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 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 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4544 KB Output is correct
11 Correct 231 ms 7436 KB Output is correct
12 Correct 232 ms 7680 KB Output is correct
13 Correct 221 ms 7252 KB Output is correct
14 Correct 254 ms 7372 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4440 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 119 ms 5712 KB Output is correct
24 Correct 78 ms 4956 KB Output is correct
25 Correct 58 ms 4828 KB Output is correct
26 Correct 48 ms 4740 KB Output is correct
27 Correct 2 ms 4440 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 6 ms 4444 KB Output is correct
33 Correct 4 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4440 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 4440 KB Output is correct
41 Correct 5 ms 4444 KB Output is correct
42 Correct 8 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 41 ms 4716 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 5 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 118 ms 5696 KB Output is correct
52 Correct 75 ms 4956 KB Output is correct
53 Correct 87 ms 5120 KB Output is correct
54 Correct 42 ms 4696 KB Output is correct
55 Correct 118 ms 5528 KB Output is correct
56 Correct 26 ms 4444 KB Output is correct
57 Correct 232 ms 7248 KB Output is correct
58 Correct 236 ms 7316 KB Output is correct
59 Correct 237 ms 7252 KB Output is correct
60 Correct 250 ms 7408 KB Output is correct
61 Incorrect 276 ms 7432 KB Output isn't correct
62 Halted 0 ms 0 KB -