Submission #638705

# Submission time Handle Problem Language Result Execution time Memory
638705 2022-09-07T04:26:17 Z jamezzz Self Study (JOI22_ho_t2) C++17
0 / 100
726 ms 2628 KB
#include <bits/stdc++.h>
using namespace std;

#define pf printf
#define sf scanf
typedef long long ll;
typedef pair<int,int> ii;

#define maxn 300005

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

int main(){
	sf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		sf("%d",&a[i]);
	}
	for(int i=0;i<n;++i){
		sf("%d",&b[i]);
	}
	ll lo=0,hi=1e18+10,mid,res=0;
	while(lo<=hi){
		mid=(lo+hi)>>1;
		ll rem=(ll)n*m;
		for(int i=0;i<n;++i){
			ll take=min((ll)m,(mid+a[i]-1)/a[i]);
			ll self=max((mid-(take*a[i])+b[i]-1)/b[i],0ll);
			ll self2=(mid+b[i]-1)/b[i];
			rem-=min(take+self,self2);
			
		}
		if(rem>=0){
			res=mid;
			lo=mid+1;
		}
		else hi=mid-1;
	}
	pf("%lld\n",res);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  sf("%d%d",&n,&m);
      |    ^
Main.cpp:16:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   sf("%d",&a[i]);
      |     ^
Main.cpp:19:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   sf("%d",&b[i]);
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 377 ms 2628 KB Output is correct
12 Correct 372 ms 2628 KB Output is correct
13 Correct 446 ms 2628 KB Output is correct
14 Incorrect 726 ms 2624 KB Output isn't correct
15 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 0 ms 212 KB Output is correct
6 Correct 0 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 193 ms 1460 KB Output is correct
10 Correct 128 ms 1068 KB Output is correct
11 Correct 94 ms 880 KB Output is correct
12 Correct 81 ms 724 KB Output is correct
13 Correct 1 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 1 ms 212 KB Output is correct
18 Incorrect 13 ms 344 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 377 ms 2628 KB Output is correct
12 Correct 372 ms 2628 KB Output is correct
13 Correct 446 ms 2628 KB Output is correct
14 Incorrect 726 ms 2624 KB Output isn't correct
15 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 0 ms 212 KB Output is correct
6 Correct 0 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 193 ms 1460 KB Output is correct
10 Correct 128 ms 1068 KB Output is correct
11 Correct 94 ms 880 KB Output is correct
12 Correct 81 ms 724 KB Output is correct
13 Correct 1 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 1 ms 212 KB Output is correct
18 Incorrect 13 ms 344 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 377 ms 2628 KB Output is correct
12 Correct 372 ms 2628 KB Output is correct
13 Correct 446 ms 2628 KB Output is correct
14 Incorrect 726 ms 2624 KB Output isn't correct
15 Halted 0 ms 0 KB -