Submission #548690

# Submission time Handle Problem Language Result Execution time Memory
548690 2022-04-14T09:15:23 Z cpp219 Self Study (JOI22_ho_t2) C++17
62 / 100
400 ms 8520 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 3e5 + 9;
const ll inf = 1e16 + 7;

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

bool chk(ll tar){
    ll spare = 0;
    for (ll i = 1;i <= n;i++){
        ll mx = max(a[i],b[i]);
        if (m*mx > tar) spare += m - ceil((ld)tar/mx);
        else spare -= ceil((ld)(tar - mx*m)/b[i]);
    }
    return (spare >= 0);
}

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>n>>m;
    for (ll i = 1;i <= n;i++) cin>>a[i];
    for (ll i = 1;i <= n;i++) cin>>b[i];
    ll l,mid,h; l = 1; h = inf; //debug(chk(18));
    while(l <= h){
        mid = (l + h)/2;
        if (chk(mid)) l = mid + 1;
        else h = mid - 1;
    }
    cout<<h;
}
/// be confident

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 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 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 12 ms 364 KB Output is correct
11 Correct 212 ms 2692 KB Output is correct
12 Correct 219 ms 8520 KB Output is correct
13 Correct 186 ms 6464 KB Output is correct
14 Correct 190 ms 6464 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 141 ms 2656 KB Output is correct
17 Correct 217 ms 2648 KB Output is correct
18 Correct 212 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 141 ms 2656 KB Output is correct
3 Correct 217 ms 2648 KB Output is correct
4 Correct 212 ms 2652 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 236 KB Output is correct
7 Correct 0 ms 340 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 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 134 ms 1368 KB Output is correct
14 Correct 110 ms 1228 KB Output is correct
15 Correct 100 ms 900 KB Output is correct
16 Correct 101 ms 708 KB Output is correct
17 Correct 2 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 4 ms 340 KB Output is correct
23 Correct 9 ms 364 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 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 12 ms 364 KB Output is correct
11 Correct 212 ms 2692 KB Output is correct
12 Correct 219 ms 8520 KB Output is correct
13 Correct 186 ms 6464 KB Output is correct
14 Correct 190 ms 6464 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 236 KB Output is correct
17 Correct 0 ms 340 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 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 134 ms 1368 KB Output is correct
24 Correct 110 ms 1228 KB Output is correct
25 Correct 100 ms 900 KB Output is correct
26 Correct 101 ms 708 KB Output is correct
27 Correct 2 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 4 ms 340 KB Output is correct
33 Correct 9 ms 364 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 141 ms 2656 KB Output is correct
36 Correct 217 ms 2648 KB Output is correct
37 Correct 212 ms 2652 KB Output is correct
38 Correct 0 ms 328 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 328 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 15 ms 468 KB Output is correct
46 Correct 7 ms 472 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 32 ms 1724 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 3 ms 340 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 107 ms 4364 KB Output is correct
56 Correct 77 ms 2432 KB Output is correct
57 Correct 59 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 236 KB Output is correct
3 Correct 0 ms 340 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 134 ms 1368 KB Output is correct
10 Correct 110 ms 1228 KB Output is correct
11 Correct 100 ms 900 KB Output is correct
12 Correct 101 ms 708 KB Output is correct
13 Correct 2 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 4 ms 340 KB Output is correct
19 Correct 9 ms 364 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 141 ms 2656 KB Output is correct
22 Correct 217 ms 2648 KB Output is correct
23 Correct 212 ms 2652 KB Output is correct
24 Correct 116 ms 628 KB Output is correct
25 Correct 148 ms 1368 KB Output is correct
26 Correct 55 ms 468 KB Output is correct
27 Correct 216 ms 2652 KB Output is correct
28 Correct 207 ms 2692 KB Output is correct
29 Correct 189 ms 2636 KB Output is correct
30 Correct 233 ms 8372 KB Output is correct
31 Incorrect 400 ms 8420 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 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 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 12 ms 364 KB Output is correct
11 Correct 212 ms 2692 KB Output is correct
12 Correct 219 ms 8520 KB Output is correct
13 Correct 186 ms 6464 KB Output is correct
14 Correct 190 ms 6464 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 236 KB Output is correct
17 Correct 0 ms 340 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 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 134 ms 1368 KB Output is correct
24 Correct 110 ms 1228 KB Output is correct
25 Correct 100 ms 900 KB Output is correct
26 Correct 101 ms 708 KB Output is correct
27 Correct 2 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 4 ms 340 KB Output is correct
33 Correct 9 ms 364 KB Output is correct
34 Correct 0 ms 328 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 328 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 15 ms 468 KB Output is correct
42 Correct 7 ms 472 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 32 ms 1724 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 107 ms 4364 KB Output is correct
52 Correct 77 ms 2432 KB Output is correct
53 Correct 59 ms 2388 KB Output is correct
54 Correct 116 ms 628 KB Output is correct
55 Correct 148 ms 1368 KB Output is correct
56 Correct 55 ms 468 KB Output is correct
57 Correct 216 ms 2652 KB Output is correct
58 Correct 207 ms 2692 KB Output is correct
59 Correct 189 ms 2636 KB Output is correct
60 Correct 233 ms 8372 KB Output is correct
61 Incorrect 400 ms 8420 KB Output isn't correct
62 Halted 0 ms 0 KB -