Submission #588071

# Submission time Handle Problem Language Result Execution time Memory
588071 2022-07-02T17:02:59 Z Mounir Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 9892 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;
long double a[N], b[N];

bool isOk(int bInf){
      signed aAllouer = 0;
      for (signed iCours = 0; iCours < nCours; ++iCours){
            signed besoin = ceil(bInf/a[iCours]);
            if (besoin <= nWeeks)
                  aAllouer += nWeeks - besoin;
            else
                  aAllouer -= ceil((bInf - nWeeks * a[iCours])/b[iCours]);
      }

    //  cout << aAllouer
      return aAllouer >= 0;
}

signed main(){ 
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cin >> nCours >> nWeeks;
      for (signed i = 0; i < nCours; ++i)
            cin >> a[i];
      for (signed i = 0; i < nCours; ++i){
            cin >> b[i];
            chmax(a[i], b[i]);
      }

      int gauche = 0, droite = nWeeks * 1e9;
      while (droite > gauche){
            int mid = (gauche + droite)/2 + 1;
            if (isOk(mid))
                  gauche = mid;
            else
                  droite = mid - 1;
      }
      cout << gauche << endl;
      return 0;   
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 220 ms 9696 KB Output is correct
12 Correct 227 ms 9892 KB Output is correct
13 Correct 172 ms 9604 KB Output is correct
14 Correct 173 ms 9720 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Execution timed out 1091 ms 9660 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1091 ms 9660 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 220 ms 9696 KB Output is correct
12 Correct 227 ms 9892 KB Output is correct
13 Correct 172 ms 9604 KB Output is correct
14 Correct 173 ms 9720 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Execution timed out 1091 ms 9660 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1091 ms 9660 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 220 ms 9696 KB Output is correct
12 Correct 227 ms 9892 KB Output is correct
13 Correct 172 ms 9604 KB Output is correct
14 Correct 173 ms 9720 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Execution timed out 1091 ms 9660 KB Time limit exceeded
17 Halted 0 ms 0 KB -