Submission #885879

# Submission time Handle Problem Language Result Execution time Memory
885879 2023-12-10T22:59:23 Z NintsiChkhaidze Self Study (JOI22_ho_t2) C++17
0 / 100
2 ms 348 KB
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define ll unsigned long long
#define int ll
using namespace std;
 
const int N = 3e5 + 3;
 
int a[N],b[N],n,m,cur[N];
 
bool check(int x){
 
	int need=0,have=0;
	for (int i = 1; i <= n; i++){
		cur[i] = max(a[i],b[i]) * m;
		if (cur[i] > x){
			have += (cur[i] - x + max(a[i],b[i]) - 1) / max(a[i],b[i]);
		}else if (cur[i] < x){
			need += (x - cur[i] + b[i] - 1)/b[i];
		}
	}
 
	if (need > n*m) return 0;
	return (have >= need);
}
 
signed main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	freopen("inpttt.txt", "r", stdin);
	cin>>n>>m;
 
	for (int i = 1; i <= n; i++) 
		cin >> a[i];
	
	for (int i = 1; i <= n; i++)
		cin >> b[i];
 
	int l = 0,r = 1e18,res=0;
	while (l <= r){
		int mid = (l + r)/2;
		if (check(mid)){
			res=mid;
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	cout<<res;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  freopen("inpttt.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -