제출 #1117507

#제출 시각아이디문제언어결과실행 시간메모리
1117507wellthen_Self Study (JOI22_ho_t2)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <climits>
using namespace std;
typedef long long ll;
bool works(ll mid, vector<ll> classes, vector<ll> selfstudy, ll n, ll m){
    //satisfy requirement for all the classes
    ll time = n*m;
    for(int i = 0; i<classes.size(); i++){
        if(classes[i] > selfstudy[i]){
            if(m * classes[i] >= mid){
                time -= (mid + classes[i] - 1) / classes[i];
            }
            else{
                time -= m;
                time -= (mid - m * classes[i] + selfstudy[i] - 1) / selfstudy[i];
            }
        }
        else {
            time -= (mid + selfstudy[i] - 1) / selfstudy[i];
        }
    }
    return time>=0;
}
int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> classes(n), selfstudy(n);
    for(int i = 0; i<n; i++){
        cin >> classes[i];
    }
    for(int i = 0; i<n; i++){
        cin >> selfstudy[i];
    ll lo = 0, hi = LLONG_MAX;
    while(lo+1<hi){
        ll mid = (lo+hi)/2;
        if(works(mid, classes, selfstudy, n, m)){
            lo = mid;
        }
        else{
            hi = mid-1;
        }
    }
    if(works(hi, classes, selfstudy, n, m)){
        cout << hi << endl;
        return 0;
    }
    cout << lo << endl;
}

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

Main.cpp: In function 'bool works(ll, std::vector<long long int>, std::vector<long long int>, ll, ll)':
Main.cpp:8:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 0; i<classes.size(); i++){
      |                    ~^~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:48:1: error: expected '}' at end of input
   48 | }
      | ^
Main.cpp:24:11: note: to match this '{'
   24 | int main(){
      |           ^