답안 #598790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598790 2022-07-19T05:13:59 Z denniskim Self Study (JOI22_ho_t2) C++17
100 / 100
254 ms 11436 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second

ll n;
ll m;
ll a[300010], b[300010];
ll l, r;

int main(void)
{
	scanf("%lld %lld", &n, &m);
	
	for(ll i = 1 ; i <= n ; i++)
		scanf("%lld", &a[i]);
	
	for(ll i = 1 ; i <= n ; i++)
		scanf("%lld", &b[i]);
	
	l = 0;
	r = 1000000000000000001;
	
	while(l + 1 < r)
	{
		ll mid = (l + r) / 2;
		ll cou = 0;
		
		for(ll i = 1 ; i <= n ; i++)
		{
			if(a[i] < b[i])
				cou += (mid + b[i] - 1) / b[i];
			
			else
			{
				if((mid + a[i] - 1) / a[i] <= m)
					cou += (mid + a[i] - 1) / a[i];
				
				else
				{
					cou += m;
					cou += (mid - a[i] * m + b[i] - 1) / b[i];
				}
			}
			
			if(cou > n * m)
				break;
		}
		
		if(cou > n * m)
			r = mid;
		else
			l = mid;
	}
	
	printf("%lld", l);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%lld %lld", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%lld", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%lld", &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 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 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 107 ms 10808 KB Output is correct
12 Correct 110 ms 10788 KB Output is correct
13 Correct 84 ms 8796 KB Output is correct
14 Correct 85 ms 8724 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 53 ms 6072 KB Output is correct
17 Correct 111 ms 11324 KB Output is correct
18 Correct 110 ms 10780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 53 ms 6072 KB Output is correct
3 Correct 111 ms 11324 KB Output is correct
4 Correct 110 ms 10780 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 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 54 ms 5428 KB Output is correct
14 Correct 36 ms 3792 KB Output is correct
15 Correct 25 ms 2900 KB Output is correct
16 Correct 22 ms 2392 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 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 308 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 4 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 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 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 107 ms 10808 KB Output is correct
12 Correct 110 ms 10788 KB Output is correct
13 Correct 84 ms 8796 KB Output is correct
14 Correct 85 ms 8724 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 304 KB Output is correct
18 Correct 0 ms 212 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 54 ms 5428 KB Output is correct
24 Correct 36 ms 3792 KB Output is correct
25 Correct 25 ms 2900 KB Output is correct
26 Correct 22 ms 2392 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 308 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 53 ms 6072 KB Output is correct
36 Correct 111 ms 11324 KB Output is correct
37 Correct 110 ms 10780 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 312 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 312 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 4 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 19 ms 2092 KB Output is correct
49 Correct 0 ms 304 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 3 ms 472 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 308 KB Output is correct
55 Correct 62 ms 5396 KB Output is correct
56 Correct 38 ms 3084 KB Output is correct
57 Correct 30 ms 3132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 304 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 54 ms 5428 KB Output is correct
10 Correct 36 ms 3792 KB Output is correct
11 Correct 25 ms 2900 KB Output is correct
12 Correct 22 ms 2392 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 53 ms 6072 KB Output is correct
22 Correct 111 ms 11324 KB Output is correct
23 Correct 110 ms 10780 KB Output is correct
24 Correct 33 ms 1812 KB Output is correct
25 Correct 80 ms 4996 KB Output is correct
26 Correct 15 ms 1340 KB Output is correct
27 Correct 109 ms 10884 KB Output is correct
28 Correct 112 ms 10848 KB Output is correct
29 Correct 115 ms 10784 KB Output is correct
30 Correct 139 ms 10788 KB Output is correct
31 Correct 224 ms 10908 KB Output is correct
32 Correct 162 ms 6168 KB Output is correct
33 Correct 237 ms 11436 KB Output is correct
34 Correct 190 ms 6152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 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 0 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 107 ms 10808 KB Output is correct
12 Correct 110 ms 10788 KB Output is correct
13 Correct 84 ms 8796 KB Output is correct
14 Correct 85 ms 8724 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 304 KB Output is correct
18 Correct 0 ms 212 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 54 ms 5428 KB Output is correct
24 Correct 36 ms 3792 KB Output is correct
25 Correct 25 ms 2900 KB Output is correct
26 Correct 22 ms 2392 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 308 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 4 ms 468 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 312 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 312 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 19 ms 2092 KB Output is correct
45 Correct 0 ms 304 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 3 ms 472 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 308 KB Output is correct
51 Correct 62 ms 5396 KB Output is correct
52 Correct 38 ms 3084 KB Output is correct
53 Correct 30 ms 3132 KB Output is correct
54 Correct 33 ms 1812 KB Output is correct
55 Correct 80 ms 4996 KB Output is correct
56 Correct 15 ms 1340 KB Output is correct
57 Correct 109 ms 10884 KB Output is correct
58 Correct 112 ms 10848 KB Output is correct
59 Correct 115 ms 10784 KB Output is correct
60 Correct 139 ms 10788 KB Output is correct
61 Correct 224 ms 10908 KB Output is correct
62 Correct 162 ms 6168 KB Output is correct
63 Correct 237 ms 11436 KB Output is correct
64 Correct 190 ms 6152 KB Output is correct
65 Correct 1 ms 304 KB Output is correct
66 Correct 53 ms 6072 KB Output is correct
67 Correct 111 ms 11324 KB Output is correct
68 Correct 110 ms 10780 KB Output is correct
69 Correct 22 ms 1364 KB Output is correct
70 Correct 7 ms 572 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 35 ms 1796 KB Output is correct
73 Correct 7 ms 564 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 146 ms 10680 KB Output is correct
76 Correct 139 ms 10788 KB Output is correct
77 Correct 139 ms 10788 KB Output is correct
78 Correct 178 ms 10764 KB Output is correct
79 Correct 238 ms 10780 KB Output is correct
80 Correct 254 ms 10784 KB Output is correct
81 Correct 230 ms 8796 KB Output is correct
82 Correct 230 ms 8800 KB Output is correct