Submission #588078

# Submission time Handle Problem Language Result Execution time Memory
588078 2022-07-02T17:10:21 Z Mounir Self Study (JOI22_ho_t2) C++14
0 / 100
1 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 signed N = 1e6;
signed nCours, nWeeks;
int a[N], b[N];
 
inline bool isOk(int bInf){
      signed aAllouer = 0;
      for (signed iCours = 0; iCours < nCours; ++iCours){
            signed besoin = ceil(bInf/(long double)a[iCours]);
            if (besoin <= nWeeks)
                  aAllouer += nWeeks - besoin;
            else
                  aAllouer -= ceil((bInf - nWeeks * a[iCours])/(long double)b[iCours]);
      }
 
    //  cout << aAllouer
      return aAllouer >= 0;
}
 
signed main(){ 
      scanf("%d%d", &nCours, &nWeeks);
      for (signed i = 0; i < nCours; ++i)
            scanf("%lld", &a[i]);
      for (signed i = 0; i < nCours; ++i){
            scanf("%lld", &b[i]);
            chmax(a[i], b[i]);
      }
 
      int gauche = 0, droite = 1e18;
      while (droite > gauche){
            int mid = (gauche + droite)/2 + 1;
            if (isOk(mid))
                  gauche = mid;
            else
                  droite = mid - 1;
      }
      printf("%lld\n", gauche);
      return 0;   
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |       scanf("%d%d", &nCours, &nWeeks);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:35:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |             scanf("%lld", &a[i]);
      |             ~~~~~^~~~~~~~~~~~~~~
Main.cpp:37:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |             scanf("%lld", &b[i]);
      |             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -