제출 #938060

#제출 시각아이디문제언어결과실행 시간메모리
938060LitusianoSelf Study (JOI22_ho_t2)C++17
100 / 100
304 ms13352 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
 
vector<pair<int,int>> v;
int n,m;
const int inf = 1e18;
bool check(int mid){
    vector<int> need(n);
    int left = 0;
    for(int i = 0; i<n && left >= 0; i++){
        int z = max(v[i].first, v[i].second);
        int k = (mid+z-1)/z;
        if(k > m) need[i] = mid-(m * z);
        else left+=m-k;
    }
    for(int i = 0; i<n && left >= 0; i++){
        left -= (need[i] + v[i].second - 1)/v[i].second;
    }
    return left>=0;
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    v.resize(n);
    for(auto& x : v) cin>>x.first; for(auto& x : v) cin>>x.second;
    int l = 0; int r = 1e18; r+= 1000;
    while(r > l+1){
        int mid = (l+r)/2;
        // cerr<<l<<" "<<r<<" "<<mid<<" "<<check(mid)<<endl;
        if(check(mid)) l = mid;
        else r = mid;
    }
    // cerr<<check(inf)<<endl;
    cout<<l<<endl;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:29:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |     for(auto& x : v) cin>>x.first; for(auto& x : v) cin>>x.second;
      |     ^~~
Main.cpp:29:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   29 |     for(auto& x : v) cin>>x.first; for(auto& x : v) cin>>x.second;
      |                                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...