Submission #955033

# Submission time Handle Problem Language Result Execution time Memory
955033 2024-03-29T08:24:33 Z sleepntsheep Self Study (JOI22_ho_t2) C
62 / 100
373 ms 7508 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];

    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=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:32:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d%d",&n,&m);
      |     ^~~~~~~~~~~~~~~~~~~
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",a+i);
      |                          ^~~~~~~~~~~~~~~
Main.c:34:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     for(int i=1;i<=n;++i)scanf("%d",b+i),a[i]=max_(a[i],b[i]);
      |                          ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4440 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 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 5 ms 4444 KB Output is correct
11 Correct 263 ms 7260 KB Output is correct
12 Correct 265 ms 7504 KB Output is correct
13 Correct 254 ms 7248 KB Output is correct
14 Correct 301 ms 7440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 358 ms 7252 KB Output is correct
17 Correct 263 ms 7436 KB Output is correct
18 Correct 261 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 358 ms 7252 KB Output is correct
3 Correct 263 ms 7436 KB Output is correct
4 Correct 261 ms 7252 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 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 131 ms 5716 KB Output is correct
14 Correct 89 ms 5128 KB Output is correct
15 Correct 66 ms 4700 KB Output is correct
16 Correct 53 ms 4696 KB Output is correct
17 Correct 2 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 7 ms 4540 KB Output is correct
23 Correct 5 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4440 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 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 5 ms 4444 KB Output is correct
11 Correct 263 ms 7260 KB Output is correct
12 Correct 265 ms 7504 KB Output is correct
13 Correct 254 ms 7248 KB Output is correct
14 Correct 301 ms 7440 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 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 131 ms 5716 KB Output is correct
24 Correct 89 ms 5128 KB Output is correct
25 Correct 66 ms 4700 KB Output is correct
26 Correct 53 ms 4696 KB Output is correct
27 Correct 2 ms 4444 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 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 7 ms 4540 KB Output is correct
33 Correct 5 ms 4440 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 358 ms 7252 KB Output is correct
36 Correct 263 ms 7436 KB Output is correct
37 Correct 261 ms 7252 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 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 9 ms 4444 KB Output is correct
47 Correct 2 ms 4444 KB Output is correct
48 Correct 46 ms 4700 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4524 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 130 ms 5548 KB Output is correct
56 Correct 87 ms 5124 KB Output is correct
57 Correct 100 ms 4956 KB Output is correct
# Verdict Execution time Memory 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 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 131 ms 5716 KB Output is correct
10 Correct 89 ms 5128 KB Output is correct
11 Correct 66 ms 4700 KB Output is correct
12 Correct 53 ms 4696 KB Output is correct
13 Correct 2 ms 4444 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 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 7 ms 4540 KB Output is correct
19 Correct 5 ms 4440 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 358 ms 7252 KB Output is correct
22 Correct 263 ms 7436 KB Output is correct
23 Correct 261 ms 7252 KB Output is correct
24 Correct 47 ms 4700 KB Output is correct
25 Correct 129 ms 5548 KB Output is correct
26 Correct 29 ms 4444 KB Output is correct
27 Correct 263 ms 7436 KB Output is correct
28 Correct 263 ms 7252 KB Output is correct
29 Correct 264 ms 7332 KB Output is correct
30 Correct 272 ms 7356 KB Output is correct
31 Correct 301 ms 7508 KB Output is correct
32 Correct 373 ms 7436 KB Output is correct
33 Incorrect 311 ms 7436 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4440 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 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 5 ms 4444 KB Output is correct
11 Correct 263 ms 7260 KB Output is correct
12 Correct 265 ms 7504 KB Output is correct
13 Correct 254 ms 7248 KB Output is correct
14 Correct 301 ms 7440 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 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 131 ms 5716 KB Output is correct
24 Correct 89 ms 5128 KB Output is correct
25 Correct 66 ms 4700 KB Output is correct
26 Correct 53 ms 4696 KB Output is correct
27 Correct 2 ms 4444 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 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 7 ms 4540 KB Output is correct
33 Correct 5 ms 4440 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 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 4440 KB Output is correct
41 Correct 5 ms 4444 KB Output is correct
42 Correct 9 ms 4444 KB Output is correct
43 Correct 2 ms 4444 KB Output is correct
44 Correct 46 ms 4700 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4524 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 130 ms 5548 KB Output is correct
52 Correct 87 ms 5124 KB Output is correct
53 Correct 100 ms 4956 KB Output is correct
54 Correct 47 ms 4700 KB Output is correct
55 Correct 129 ms 5548 KB Output is correct
56 Correct 29 ms 4444 KB Output is correct
57 Correct 263 ms 7436 KB Output is correct
58 Correct 263 ms 7252 KB Output is correct
59 Correct 264 ms 7332 KB Output is correct
60 Correct 272 ms 7356 KB Output is correct
61 Correct 301 ms 7508 KB Output is correct
62 Correct 373 ms 7436 KB Output is correct
63 Incorrect 311 ms 7436 KB Output isn't correct
64 Halted 0 ms 0 KB -