Submission #1018846

# Submission time Handle Problem Language Result Execution time Memory
1018846 2024-07-10T10:11:09 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
348 ms 16172 KB
#include <bits/stdc++.h>
#define int long long
#define Aiko ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define pb push_back
using namespace std;
const int  INF=1e18;
bool fun(int n, vector<int>a,int t,vector<int>b){
	int ans=0;
	for(int i=0;i<a.size();i++){
		if(a[i]<b[i]){
			ans+=((n+b[i]-1)/b[i]);
		}else{
			if(a[i]*t>=n){
				ans+=(n+a[i]-1)/a[i];
			}else{
				ans+=(n-a[i]*t+b[i]-1)/b[i];
				ans+=t;
			}
		}
		if(ans>t*a.size())return false;
	}
	if(ans<=t*a.size())return true;
	else return false;
}
signed main(){
	int n, k, i, j, m, mn=INF, t;cin>>n>>k;
	vector<int>a(n),b(n);
	for(i=0;i<n;i++){
		cin>>a[i];
		mn=min(mn,a[i]);
	}
	for(i=0;i<n;i++){
		cin>>b[i];
		mn=min(mn,b[i]);
	}
	int l=1, r=1e18+1;
	while(r>l+1){
		int m=(l+r)>>1;
		if(fun(m,a,k,b))l=m;
		else r=m;
	}
	if(fun(r,a,k,b))cout<<r;
	else cout<<l;
}		

Compilation message

Main.cpp: In function 'bool fun(long long int, std::vector<long long int>, long long int, std::vector<long long int>)':
Main.cpp:9:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<a.size();i++){
      |              ~^~~~~~~~~
Main.cpp:20:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   20 |   if(ans>t*a.size())return false;
      |      ~~~^~~~~~~~~~~
Main.cpp:22:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   22 |  if(ans<=t*a.size())return true;
      |     ~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:26:15: warning: unused variable 'j' [-Wunused-variable]
   26 |  int n, k, i, j, m, mn=INF, t;cin>>n>>k;
      |               ^
Main.cpp:26:18: warning: unused variable 'm' [-Wunused-variable]
   26 |  int n, k, i, j, m, mn=INF, t;cin>>n>>k;
      |                  ^
Main.cpp:26:29: warning: unused variable 't' [-Wunused-variable]
   26 |  int n, k, i, j, m, mn=INF, t;cin>>n>>k;
      |                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 420 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 277 ms 15484 KB Output is correct
12 Correct 330 ms 15516 KB Output is correct
13 Correct 204 ms 13752 KB Output is correct
14 Correct 201 ms 13780 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 135 ms 11208 KB Output is correct
17 Correct 251 ms 16172 KB Output is correct
18 Correct 269 ms 15472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 135 ms 11208 KB Output is correct
3 Correct 251 ms 16172 KB Output is correct
4 Correct 269 ms 15472 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 123 ms 8304 KB Output is correct
14 Correct 88 ms 5596 KB Output is correct
15 Correct 59 ms 4404 KB Output is correct
16 Correct 58 ms 3452 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 420 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 277 ms 15484 KB Output is correct
12 Correct 330 ms 15516 KB Output is correct
13 Correct 204 ms 13752 KB Output is correct
14 Correct 201 ms 13780 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 123 ms 8304 KB Output is correct
24 Correct 88 ms 5596 KB Output is correct
25 Correct 59 ms 4404 KB Output is correct
26 Correct 58 ms 3452 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 135 ms 11208 KB Output is correct
36 Correct 251 ms 16172 KB Output is correct
37 Correct 269 ms 15472 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 852 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 3 ms 604 KB Output is correct
46 Correct 6 ms 880 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 48 ms 3208 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 432 KB Output is correct
51 Correct 3 ms 600 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 131 ms 8040 KB Output is correct
56 Correct 67 ms 4820 KB Output is correct
57 Correct 65 ms 5016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 123 ms 8304 KB Output is correct
10 Correct 88 ms 5596 KB Output is correct
11 Correct 59 ms 4404 KB Output is correct
12 Correct 58 ms 3452 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 135 ms 11208 KB Output is correct
22 Correct 251 ms 16172 KB Output is correct
23 Correct 269 ms 15472 KB Output is correct
24 Correct 39 ms 2944 KB Output is correct
25 Correct 112 ms 7320 KB Output is correct
26 Correct 25 ms 2040 KB Output is correct
27 Correct 254 ms 15488 KB Output is correct
28 Correct 249 ms 15620 KB Output is correct
29 Correct 250 ms 15544 KB Output is correct
30 Correct 286 ms 15484 KB Output is correct
31 Correct 260 ms 15468 KB Output is correct
32 Correct 193 ms 11112 KB Output is correct
33 Correct 293 ms 16132 KB Output is correct
34 Correct 164 ms 11084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 420 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 277 ms 15484 KB Output is correct
12 Correct 330 ms 15516 KB Output is correct
13 Correct 204 ms 13752 KB Output is correct
14 Correct 201 ms 13780 KB Output is correct
15 Correct 0 ms 436 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 123 ms 8304 KB Output is correct
24 Correct 88 ms 5596 KB Output is correct
25 Correct 59 ms 4404 KB Output is correct
26 Correct 58 ms 3452 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 3 ms 604 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 852 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 3 ms 604 KB Output is correct
42 Correct 6 ms 880 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 48 ms 3208 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 432 KB Output is correct
47 Correct 3 ms 600 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 131 ms 8040 KB Output is correct
52 Correct 67 ms 4820 KB Output is correct
53 Correct 65 ms 5016 KB Output is correct
54 Correct 39 ms 2944 KB Output is correct
55 Correct 112 ms 7320 KB Output is correct
56 Correct 25 ms 2040 KB Output is correct
57 Correct 254 ms 15488 KB Output is correct
58 Correct 249 ms 15620 KB Output is correct
59 Correct 250 ms 15544 KB Output is correct
60 Correct 286 ms 15484 KB Output is correct
61 Correct 260 ms 15468 KB Output is correct
62 Correct 193 ms 11112 KB Output is correct
63 Correct 293 ms 16132 KB Output is correct
64 Correct 164 ms 11084 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 135 ms 11208 KB Output is correct
67 Correct 251 ms 16172 KB Output is correct
68 Correct 269 ms 15472 KB Output is correct
69 Correct 33 ms 2052 KB Output is correct
70 Correct 6 ms 700 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 42 ms 2824 KB Output is correct
73 Correct 10 ms 932 KB Output is correct
74 Correct 2 ms 348 KB Output is correct
75 Correct 288 ms 15304 KB Output is correct
76 Correct 303 ms 15352 KB Output is correct
77 Correct 311 ms 15292 KB Output is correct
78 Correct 315 ms 15476 KB Output is correct
79 Correct 322 ms 15324 KB Output is correct
80 Correct 348 ms 15272 KB Output is correct
81 Correct 255 ms 13528 KB Output is correct
82 Correct 247 ms 13628 KB Output is correct