Submission #588103

# Submission time Handle Problem Language Result Execution time Memory
588103 2022-07-02T17:24:51 Z Mounir Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 4940 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 = 3e5;
int nCours, nWeeks;
int a[N], b[N];
 
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(){ 
      scanf("%d%d", &nCours, &nWeeks);
      for (int i = 0; i < nCours; ++i)
            scanf("%d", &a[i]);
      for (int i = 0; i < nCours; ++i){
            scanf("%d", &b[i]);
            chmax(a[i], b[i]);
      }
 
      long long gauche = 0, droite = 1e18;
      while (droite > gauche){
            long long mid = (gauche + droite + 1)/2;
            if (isOk(mid))
                  gauche = mid;
            else
                  droite = mid - 1;
      }
      cout << gauche << endl;
      return 0;   
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:15: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   36 |       scanf("%d%d", &nCours, &nWeeks);
      |              ~^     ~~~~~~~
      |               |     |
      |               int*  long long int*
      |              %lld
Main.cpp:36:17: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   36 |       scanf("%d%d", &nCours, &nWeeks);
      |                ~^            ~~~~~~~
      |                 |            |
      |                 int*         long long int*
      |                %lld
Main.cpp:38:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   38 |             scanf("%d", &a[i]);
      |                    ~^   ~~~~~
      |                     |   |
      |                     |   long long int*
      |                     int*
      |                    %lld
Main.cpp:40:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   40 |             scanf("%d", &b[i]);
      |                    ~^   ~~~~~
      |                     |   |
      |                     |   long long int*
      |                     int*
      |                    %lld
Main.cpp:36:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |       scanf("%d%d", &nCours, &nWeeks);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |             scanf("%d", &a[i]);
      |             ~~~~~^~~~~~~~~~~~~
Main.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             scanf("%d", &b[i]);
      |             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 40 ms 340 KB Output is correct
11 Execution timed out 1089 ms 4940 KB Time limit exceeded
12 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Execution timed out 1087 ms 2632 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 40 ms 340 KB Output is correct
11 Execution timed out 1089 ms 4940 KB Time limit exceeded
12 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Execution timed out 1087 ms 2632 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 40 ms 340 KB Output is correct
11 Execution timed out 1089 ms 4940 KB Time limit exceeded
12 Halted 0 ms 0 KB -