Submission #719313

# Submission time Handle Problem Language Result Execution time Memory
719313 2023-04-05T18:08:51 Z hariaakas646 Self Study (JOI22_ho_t2) C++17
100 / 100
258 ms 11368 KB
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

lli n, m;
bool check(lli x, vll &v1, vll &v2)
{
    lli tot = 0;
    frange(i, n)
    {
        lli e1 = v1[i];
        lli e2 = v2[i];

        lli tmp = x;
        lli v = (tmp + e1 - 1) / e1;
        tmp -= e1 * min(m, v);
        tot += min(m, v);
        if (tmp > 0)
        {
            v = (tmp + e2 - 1) / e2;
            tot += v;
        }
        if (tot > n * m)
            return false;
    }
    return tot <= n * m;
}

int main()
{

    sclld(n);
    sclld(m);
    vll vec1(n);
    vll vec2(n);
    frange(i, n)
    {
        sclld(vec1[i]);
    }
    frange(i, n)
    {
        lli a;
        sclld(a);
        vec2[i] = a;
        vec1[i] = max(vec1[i], a);
    }
    // mi = *min_element(all(vec));
    lli hi = 1e18;
    lli lo = 0;
    while (hi != lo)
    {
        lli mid = (hi + lo + 1) / 2;
        if (check(mid, vec1, vec2))
        {
            lo = mid;
        }
        else
        {
            hi = mid - 1;
        }
    }
    printf("%lld", lo);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:63:5: note: in expansion of macro 'sclld'
   63 |     sclld(n);
      |     ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:64:5: note: in expansion of macro 'sclld'
   64 |     sclld(m);
      |     ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:69:9: note: in expansion of macro 'sclld'
   69 |         sclld(vec1[i]);
      |         ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:74:9: note: in expansion of macro 'sclld'
   74 |         sclld(a);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 115 ms 10748 KB Output is correct
12 Correct 120 ms 10796 KB Output is correct
13 Correct 107 ms 8680 KB Output is correct
14 Correct 87 ms 8692 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 51 ms 6060 KB Output is correct
17 Correct 124 ms 11368 KB Output is correct
18 Correct 109 ms 10784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 51 ms 6060 KB Output is correct
3 Correct 124 ms 11368 KB Output is correct
4 Correct 109 ms 10784 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 57 ms 5540 KB Output is correct
14 Correct 39 ms 3772 KB Output is correct
15 Correct 29 ms 2900 KB Output is correct
16 Correct 26 ms 2380 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 115 ms 10748 KB Output is correct
12 Correct 120 ms 10796 KB Output is correct
13 Correct 107 ms 8680 KB Output is correct
14 Correct 87 ms 8692 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 57 ms 5540 KB Output is correct
24 Correct 39 ms 3772 KB Output is correct
25 Correct 29 ms 2900 KB Output is correct
26 Correct 26 ms 2380 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 436 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 51 ms 6060 KB Output is correct
36 Correct 124 ms 11368 KB Output is correct
37 Correct 109 ms 10784 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 300 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 6 ms 596 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 22 ms 1996 KB Output is correct
49 Correct 1 ms 216 KB Output is correct
50 Correct 1 ms 304 KB Output is correct
51 Correct 3 ms 348 KB Output is correct
52 Correct 1 ms 220 KB Output is correct
53 Correct 0 ms 220 KB Output is correct
54 Correct 1 ms 220 KB Output is correct
55 Correct 62 ms 5432 KB Output is correct
56 Correct 42 ms 3012 KB Output is correct
57 Correct 29 ms 3148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 57 ms 5540 KB Output is correct
10 Correct 39 ms 3772 KB Output is correct
11 Correct 29 ms 2900 KB Output is correct
12 Correct 26 ms 2380 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 436 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 51 ms 6060 KB Output is correct
22 Correct 124 ms 11368 KB Output is correct
23 Correct 109 ms 10784 KB Output is correct
24 Correct 37 ms 1884 KB Output is correct
25 Correct 91 ms 5004 KB Output is correct
26 Correct 17 ms 1408 KB Output is correct
27 Correct 117 ms 10792 KB Output is correct
28 Correct 119 ms 10864 KB Output is correct
29 Correct 123 ms 10888 KB Output is correct
30 Correct 154 ms 10728 KB Output is correct
31 Correct 233 ms 10728 KB Output is correct
32 Correct 168 ms 6156 KB Output is correct
33 Correct 233 ms 11368 KB Output is correct
34 Correct 182 ms 6156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 115 ms 10748 KB Output is correct
12 Correct 120 ms 10796 KB Output is correct
13 Correct 107 ms 8680 KB Output is correct
14 Correct 87 ms 8692 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 57 ms 5540 KB Output is correct
24 Correct 39 ms 3772 KB Output is correct
25 Correct 29 ms 2900 KB Output is correct
26 Correct 26 ms 2380 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 436 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 300 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 6 ms 596 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 22 ms 1996 KB Output is correct
45 Correct 1 ms 216 KB Output is correct
46 Correct 1 ms 304 KB Output is correct
47 Correct 3 ms 348 KB Output is correct
48 Correct 1 ms 220 KB Output is correct
49 Correct 0 ms 220 KB Output is correct
50 Correct 1 ms 220 KB Output is correct
51 Correct 62 ms 5432 KB Output is correct
52 Correct 42 ms 3012 KB Output is correct
53 Correct 29 ms 3148 KB Output is correct
54 Correct 37 ms 1884 KB Output is correct
55 Correct 91 ms 5004 KB Output is correct
56 Correct 17 ms 1408 KB Output is correct
57 Correct 117 ms 10792 KB Output is correct
58 Correct 119 ms 10864 KB Output is correct
59 Correct 123 ms 10888 KB Output is correct
60 Correct 154 ms 10728 KB Output is correct
61 Correct 233 ms 10728 KB Output is correct
62 Correct 168 ms 6156 KB Output is correct
63 Correct 233 ms 11368 KB Output is correct
64 Correct 182 ms 6156 KB Output is correct
65 Correct 1 ms 300 KB Output is correct
66 Correct 51 ms 6060 KB Output is correct
67 Correct 124 ms 11368 KB Output is correct
68 Correct 109 ms 10784 KB Output is correct
69 Correct 26 ms 1364 KB Output is correct
70 Correct 7 ms 468 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 39 ms 1748 KB Output is correct
73 Correct 8 ms 644 KB Output is correct
74 Correct 1 ms 328 KB Output is correct
75 Correct 121 ms 10724 KB Output is correct
76 Correct 140 ms 10784 KB Output is correct
77 Correct 148 ms 10740 KB Output is correct
78 Correct 188 ms 10732 KB Output is correct
79 Correct 255 ms 10784 KB Output is correct
80 Correct 258 ms 10780 KB Output is correct
81 Correct 232 ms 8792 KB Output is correct
82 Correct 242 ms 8812 KB Output is correct