Submission #528057

#TimeUsernameProblemLanguageResultExecution timeMemory
528057amukkalirSelf Study (JOI22_ho_t2)C++17
100 / 100
297 ms9604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define prn printf #define scn scanf const int nax = 3e5; ll n, m; ll a[nax+5], b[nax+5]; unsigned long long updiv(ll a, ll b) { ll ret = a/b; if(ret*b < a) ret++; return ret; } bool ok (ll x) { unsigned long long cnt = 0; for(int i=0; i<n; i++) { ll rem = x; ll cur = 0; if(a[i] > b[i]) { cur += min((unsigned long long)m,updiv(rem, a[i])); rem -= cur*a[i]; } if(rem>0) cur += updiv(rem, b[i]); cnt += (unsigned long long) cur; if(cnt > n*m) return false; } return cnt <= n*m; } signed main () { scn("%d%d", &n,&m); for(int i=0; i<n; i++) scn("%lld", &a[i]); for(int i=0; i<n; i++) scn("%lld", &b[i]); ll ans = 0; ll lo = 0, hi = 1e18; while(lo <= hi) { ll mid = (lo+hi)>>1; if(ok(mid)) { ans = mid; lo = mid+1; } else hi = mid-1; } prn("%lld", ans); } /* dari 3e5 slot buat setiap mapel mau study berapa kali */

Compilation message (stderr)

Main.cpp: In function 'bool ok(ll)':
Main.cpp:29:16: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   29 |         if(cnt > n*m) return false;
      |            ~~~~^~~~~
Main.cpp:31:16: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   31 |     return cnt <= n*m;
      |            ~~~~^~~~~~
Main.cpp: In function 'int main()':
Main.cpp:35:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   35 |     scn("%d%d", &n,&m);
      |          ~^     ~~
      |           |     |
      |           int*  ll* {aka long long int*}
      |          %lld
Main.cpp:35:13: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   35 |     scn("%d%d", &n,&m);
      |            ~^      ~~
      |             |      |
      |             int*   ll* {aka long long int*}
      |            %lld
Main.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scn("%d%d", &n,&m);
      |        ^
Main.cpp:36:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     for(int i=0; i<n; i++) scn("%lld", &a[i]);
      |                               ^
Main.cpp:37:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     for(int i=0; i<n; i++) scn("%lld", &b[i]);
      |                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...