| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 651855 | beaconmc | Self Study (JOI22_ho_t2) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll n,m;
vector<ll> lis;
vector<ll> lis2;
bool check(ll a){
ll cnt = 0;
FOR(i,0,n){
if (lis[i] > lis2[i]){
if (a>lis[i]*m){
cnt += (a-(lis[i]*m)-1)/lis2[i]+1 + m;
}else{
cnt += (a-1)/lis[i];
}
}else{
cnt += (a-1)/lis2[i];
}
}
if (cnt <= n*m){
return true;
}return false;
}
int main(){
ll lo = 0;
ll hi = 100000000000000000;
while (lo<hi){
ll mid = (lo+hi+1)/2;
if (check(mid)){
lo = mid;
}else{
hi = mid - 1
}
}
cout << lo;
}
