답안 #588090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
588090 2022-07-02T17:18:49 Z Mounir Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 212 KB
#include <bits/stdc++.h>
//#define all(v) v.begin(), v.end()
//#define sz(x) (int)x.size()
//#define pb push_back
//#define pii pair<int, int>
//#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
//#define print(x) cout << #x << " est " << x << endl;
//#define x first
//#define y second
///#define int long long
using namespace std;
 
const int N = 1e6;
int nCours, nWeeks;
int a[N], b[N];
 
inline bool isOk(long long bInf){
      long long aAllouer = 0;
      for (int iCours = 0; iCours < nCours; ++iCours){
            long long besoin = ceil(bInf/(long double)(a[iCours]));
            if (besoin <= nWeeks)
                  aAllouer += nWeeks - besoin;
            else {
                  long long reste = bInf - nWeeks * a[iCours];
                  reste = ceil((long double)(reste)/b[iCours]);
                  aAllouer -= reste;
            }
      }
 
    //  cout << aAllouer
      return (aAllouer >= 0ll);
}
 
signed main(){ 
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cin >> nCours >> nWeeks;
      for (int i = 0; i < nCours; ++i)
            cin >> a[i];
      for (int i = 0; i < nCours; ++i){
            cin >> b[i];
            chmax(a[i], b[i]);
      }
 
      long long gauche = 0, droite = 1e18;
      while (droite > gauche){
            int mid = (gauche + droite + 1)/2;
            if (isOk(mid))
                  gauche = mid;
            else
                  droite = mid - 1;
      }
      cout << gauche << endl;
      return 0;   
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -