이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define all(X) X.begin(),X.end()
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#ifdef local
void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
void setio(){}
#define debug(x...)
#endif
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
setio();
int n,m;
cin>>n>>m;
vector<pair<__int128,__int128>>v;
for(int i=0;i<n;i++){
int a;
cin>>a;
v.pb({a,0});
}
for(int i=0;i<n;i++){
int a;
cin>>a;
v[i].S=a;
}
__int128 l=0,r=(__int128)2e18+10;
while(l<r){
__int128 mm=l+r+1>>1;
__int128 left=0;
bool ok=1;
for(int i=0;i<n;i++){
if(v[i].F>=v[i].S){
if(v[i].F*m>mm){
__int128 x=ceil((long double)mm/v[i].F);
left+=m-x;
}
else{
__int128 cur=mm;
cur-=m*v[i].F;
__int128 x=ceil((long double)cur/v[i].S);
left-=x;
}
}
else{
left+=m;
__int128 x=ceil((long double)mm/v[i].S);
left-=x;
}
}
if(left>=0){
l=mm;
}
else{
r=mm-1;
}
}
cout<<(int)l<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:37:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
37 | __int128 mm=l+r+1>>1;
| ~~~^~
Main.cpp:39:14: warning: unused variable 'ok' [-Wunused-variable]
39 | bool ok=1;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |