Submission #819384

# Submission time Handle Problem Language Result Execution time Memory
819384 2023-08-10T10:00:17 Z tset Self Study (JOI22_ho_t2) C++14
100 / 100
226 ms 17116 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long


signed main()
{
    int N, M;
    scanf("%lld%lld", &N, &M);
    vector<int> Ai(N), Bi(N);
    for(int ai = 0; ai < N; ai++)
    {
        scanf("%lld", &Ai[ai]);
    }
    for(int bi = 0; bi< N; bi++)
    {
        scanf("%lld", &Bi[bi]);
    }
    vector<int> famille1;
    vector<pair<int, int>> famille2;

    for(int iN = 0; iN < N; iN++)
    {
        if(Bi[iN] >= Ai[iN])
        {
            famille1.push_back(Bi[iN]);
        }
        else
        {
            famille2.push_back({Ai[iN], Bi[iN]});
        }
    }
    int pas = 1LL<<60LL;
    int pos = 0;
    while(pas > 0)
    {
        int ptsMin = pos + pas;
        if(ptsMin > 1LL<<60LL)
        {
            pas/=2;
            continue;
        }
        int nbCoursesReq = 0;
        for(int iC : famille1)
        {
            nbCoursesReq += (ptsMin+iC-1)/iC;
            if(nbCoursesReq > N*M)
            {
                break;
            }
        }
        for(pair<int, int> iC : famille2 )
        {
            int ptsA = iC.first * M;
            if(ptsA >= ptsMin)
            {
                nbCoursesReq += (ptsMin + iC.first-1)/iC.first;
            }
            else
            {
                nbCoursesReq += M;
                int ptsRest =  ptsMin - ptsA;
                nbCoursesReq += (ptsRest+iC.second-1)/iC.second;
            }
            if(nbCoursesReq > N*M)
            {
                break;
            }
        }
        if(nbCoursesReq <= M * N)
        {
            pos += pas;
        }
        pas/= 2;
    }
    printf("%lld\n", pos);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%lld%lld", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld", &Ai[ai]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld", &Bi[bi]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 90 ms 10148 KB Output is correct
12 Correct 93 ms 10160 KB Output is correct
13 Correct 73 ms 9208 KB Output is correct
14 Correct 70 ms 13304 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 38 ms 9140 KB Output is correct
17 Correct 93 ms 15596 KB Output is correct
18 Correct 95 ms 14952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 38 ms 9140 KB Output is correct
3 Correct 93 ms 15596 KB Output is correct
4 Correct 95 ms 14952 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 44 ms 4808 KB Output is correct
14 Correct 29 ms 3020 KB Output is correct
15 Correct 24 ms 2628 KB Output is correct
16 Correct 19 ms 1892 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 90 ms 10148 KB Output is correct
12 Correct 93 ms 10160 KB Output is correct
13 Correct 73 ms 9208 KB Output is correct
14 Correct 70 ms 13304 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 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 44 ms 4808 KB Output is correct
24 Correct 29 ms 3020 KB Output is correct
25 Correct 24 ms 2628 KB Output is correct
26 Correct 19 ms 1892 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 38 ms 9140 KB Output is correct
36 Correct 93 ms 15596 KB Output is correct
37 Correct 95 ms 14952 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 3 ms 820 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 17 ms 2860 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 3 ms 596 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 48 ms 8240 KB Output is correct
56 Correct 28 ms 4292 KB Output is correct
57 Correct 26 ms 5308 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 44 ms 4808 KB Output is correct
10 Correct 29 ms 3020 KB Output is correct
11 Correct 24 ms 2628 KB Output is correct
12 Correct 19 ms 1892 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 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 38 ms 9140 KB Output is correct
22 Correct 93 ms 15596 KB Output is correct
23 Correct 95 ms 14952 KB Output is correct
24 Correct 29 ms 2580 KB Output is correct
25 Correct 73 ms 7104 KB Output is correct
26 Correct 11 ms 1688 KB Output is correct
27 Correct 87 ms 14948 KB Output is correct
28 Correct 92 ms 14936 KB Output is correct
29 Correct 93 ms 14952 KB Output is correct
30 Correct 118 ms 14948 KB Output is correct
31 Correct 189 ms 14944 KB Output is correct
32 Correct 118 ms 10300 KB Output is correct
33 Correct 226 ms 15580 KB Output is correct
34 Correct 117 ms 10352 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 90 ms 10148 KB Output is correct
12 Correct 93 ms 10160 KB Output is correct
13 Correct 73 ms 9208 KB Output is correct
14 Correct 70 ms 13304 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 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 44 ms 4808 KB Output is correct
24 Correct 29 ms 3020 KB Output is correct
25 Correct 24 ms 2628 KB Output is correct
26 Correct 19 ms 1892 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 3 ms 820 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 17 ms 2860 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 596 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 48 ms 8240 KB Output is correct
52 Correct 28 ms 4292 KB Output is correct
53 Correct 26 ms 5308 KB Output is correct
54 Correct 29 ms 2580 KB Output is correct
55 Correct 73 ms 7104 KB Output is correct
56 Correct 11 ms 1688 KB Output is correct
57 Correct 87 ms 14948 KB Output is correct
58 Correct 92 ms 14936 KB Output is correct
59 Correct 93 ms 14952 KB Output is correct
60 Correct 118 ms 14948 KB Output is correct
61 Correct 189 ms 14944 KB Output is correct
62 Correct 118 ms 10300 KB Output is correct
63 Correct 226 ms 15580 KB Output is correct
64 Correct 117 ms 10352 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 38 ms 9140 KB Output is correct
67 Correct 93 ms 15596 KB Output is correct
68 Correct 95 ms 14952 KB Output is correct
69 Correct 19 ms 1832 KB Output is correct
70 Correct 5 ms 724 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 30 ms 2476 KB Output is correct
73 Correct 7 ms 908 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 97 ms 16092 KB Output is correct
76 Correct 107 ms 15948 KB Output is correct
77 Correct 117 ms 16088 KB Output is correct
78 Correct 151 ms 16924 KB Output is correct
79 Correct 198 ms 16864 KB Output is correct
80 Correct 209 ms 15952 KB Output is correct
81 Correct 209 ms 13024 KB Output is correct
82 Correct 155 ms 17116 KB Output is correct