답안 #699094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699094 2023-02-15T15:14:41 Z dkblossom Self Study (JOI22_ho_t2) C++14
100 / 100
222 ms 11384 KB
#include<bits/stdc++.h>
using namespace std;

#pragma gcc optimize('ofast','unroll-loops')

#define endl '\n'
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(a,b,c) for(ll a=b;a<c;a++)

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll maxn = 300005;
const ll maxm = 200005;
const ll mod = 1000000007;

void solve(){
	ll n, m;
	ll arr[maxn];
	ll brr[maxn];

	cin >> n >> m;
	rep(i,0,n) cin >> arr[i];
	rep(i,0,n) cin >> brr[i];
	rep(i,0,n) arr[i] = max(arr[i],brr[i]);

	ll l = 0;
	ll r = 1ll<<60;

	while(l+1<r){
		ll mid = (l+r)/2;
		ll ac = 0;
		//cout<<mid<<endl;
		rep(i,0,n){
			if(arr[i]*m>=mid) ac += (mid+arr[i]-1ll)/arr[i];
			else ac += m+(mid-arr[i]*m+brr[i]-1ll)/brr[i];
			//cout << ac << ' ';
			if(ac>n*m) break;
		}//cout<<endl;
		if(ac>n*m) r = mid;
		else l = mid;
	}

	//cout<<(-1)/2<<endl;//int mid=18,ac=0;rep(i,0,n){if(arr[i]*m>=mid)ac-=m-(mid-1)/arr[i]-1;else ac+=(mid-arr[i]*m-1)/brr[i]+1;}cout<<ac<<endl;

	cout << l << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("sol.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Compilation message

Main.cpp:4: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    4 | #pragma gcc optimize('ofast','unroll-loops')
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 95 ms 4948 KB Output is correct
12 Correct 93 ms 4996 KB Output is correct
13 Correct 78 ms 4996 KB Output is correct
14 Correct 69 ms 4980 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 36 ms 5008 KB Output is correct
17 Correct 104 ms 11384 KB Output is correct
18 Correct 96 ms 10792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 36 ms 5008 KB Output is correct
3 Correct 104 ms 11384 KB Output is correct
4 Correct 96 ms 10792 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 50 ms 4948 KB Output is correct
14 Correct 32 ms 4948 KB Output is correct
15 Correct 25 ms 4948 KB Output is correct
16 Correct 21 ms 4948 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4960 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 5 ms 5076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 95 ms 4948 KB Output is correct
12 Correct 93 ms 4996 KB Output is correct
13 Correct 78 ms 4996 KB Output is correct
14 Correct 69 ms 4980 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 2 ms 4948 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 50 ms 4948 KB Output is correct
24 Correct 32 ms 4948 KB Output is correct
25 Correct 25 ms 4948 KB Output is correct
26 Correct 21 ms 4948 KB Output is correct
27 Correct 2 ms 4948 KB Output is correct
28 Correct 2 ms 4960 KB Output is correct
29 Correct 2 ms 4948 KB Output is correct
30 Correct 2 ms 4948 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 2 ms 4948 KB Output is correct
35 Correct 36 ms 5008 KB Output is correct
36 Correct 104 ms 11384 KB Output is correct
37 Correct 96 ms 10792 KB Output is correct
38 Correct 3 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 4 ms 4948 KB Output is correct
42 Correct 2 ms 5008 KB Output is correct
43 Correct 2 ms 5012 KB Output is correct
44 Correct 2 ms 5012 KB Output is correct
45 Correct 4 ms 5112 KB Output is correct
46 Correct 5 ms 5076 KB Output is correct
47 Correct 3 ms 4948 KB Output is correct
48 Correct 19 ms 5924 KB Output is correct
49 Correct 2 ms 4948 KB Output is correct
50 Correct 3 ms 4948 KB Output is correct
51 Correct 5 ms 5076 KB Output is correct
52 Correct 3 ms 4948 KB Output is correct
53 Correct 3 ms 5008 KB Output is correct
54 Correct 3 ms 4948 KB Output is correct
55 Correct 55 ms 7808 KB Output is correct
56 Correct 32 ms 6224 KB Output is correct
57 Correct 25 ms 6276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 50 ms 4948 KB Output is correct
10 Correct 32 ms 4948 KB Output is correct
11 Correct 25 ms 4948 KB Output is correct
12 Correct 21 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 2 ms 4960 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 2 ms 4948 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 5 ms 5076 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 36 ms 5008 KB Output is correct
22 Correct 104 ms 11384 KB Output is correct
23 Correct 96 ms 10792 KB Output is correct
24 Correct 31 ms 5800 KB Output is correct
25 Correct 73 ms 7588 KB Output is correct
26 Correct 16 ms 5620 KB Output is correct
27 Correct 97 ms 10784 KB Output is correct
28 Correct 101 ms 10732 KB Output is correct
29 Correct 109 ms 10700 KB Output is correct
30 Correct 130 ms 10740 KB Output is correct
31 Correct 211 ms 10792 KB Output is correct
32 Correct 99 ms 6160 KB Output is correct
33 Correct 202 ms 11352 KB Output is correct
34 Correct 116 ms 6140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 95 ms 4948 KB Output is correct
12 Correct 93 ms 4996 KB Output is correct
13 Correct 78 ms 4996 KB Output is correct
14 Correct 69 ms 4980 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 2 ms 4948 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 50 ms 4948 KB Output is correct
24 Correct 32 ms 4948 KB Output is correct
25 Correct 25 ms 4948 KB Output is correct
26 Correct 21 ms 4948 KB Output is correct
27 Correct 2 ms 4948 KB Output is correct
28 Correct 2 ms 4960 KB Output is correct
29 Correct 2 ms 4948 KB Output is correct
30 Correct 2 ms 4948 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 3 ms 4948 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 4 ms 4948 KB Output is correct
38 Correct 2 ms 5008 KB Output is correct
39 Correct 2 ms 5012 KB Output is correct
40 Correct 2 ms 5012 KB Output is correct
41 Correct 4 ms 5112 KB Output is correct
42 Correct 5 ms 5076 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 19 ms 5924 KB Output is correct
45 Correct 2 ms 4948 KB Output is correct
46 Correct 3 ms 4948 KB Output is correct
47 Correct 5 ms 5076 KB Output is correct
48 Correct 3 ms 4948 KB Output is correct
49 Correct 3 ms 5008 KB Output is correct
50 Correct 3 ms 4948 KB Output is correct
51 Correct 55 ms 7808 KB Output is correct
52 Correct 32 ms 6224 KB Output is correct
53 Correct 25 ms 6276 KB Output is correct
54 Correct 31 ms 5800 KB Output is correct
55 Correct 73 ms 7588 KB Output is correct
56 Correct 16 ms 5620 KB Output is correct
57 Correct 97 ms 10784 KB Output is correct
58 Correct 101 ms 10732 KB Output is correct
59 Correct 109 ms 10700 KB Output is correct
60 Correct 130 ms 10740 KB Output is correct
61 Correct 211 ms 10792 KB Output is correct
62 Correct 99 ms 6160 KB Output is correct
63 Correct 202 ms 11352 KB Output is correct
64 Correct 116 ms 6140 KB Output is correct
65 Correct 2 ms 4948 KB Output is correct
66 Correct 36 ms 5008 KB Output is correct
67 Correct 104 ms 11384 KB Output is correct
68 Correct 96 ms 10792 KB Output is correct
69 Correct 24 ms 5720 KB Output is correct
70 Correct 8 ms 5156 KB Output is correct
71 Correct 2 ms 5008 KB Output is correct
72 Correct 32 ms 5844 KB Output is correct
73 Correct 9 ms 5204 KB Output is correct
74 Correct 3 ms 4948 KB Output is correct
75 Correct 102 ms 10744 KB Output is correct
76 Correct 109 ms 10700 KB Output is correct
77 Correct 145 ms 10828 KB Output is correct
78 Correct 154 ms 10788 KB Output is correct
79 Correct 201 ms 10732 KB Output is correct
80 Correct 222 ms 10864 KB Output is correct
81 Correct 200 ms 8804 KB Output is correct
82 Correct 162 ms 8700 KB Output is correct