Submission #1147865

#TimeUsernameProblemLanguageResultExecution timeMemory
1147865minggaSelf Study (JOI22_ho_t2)C++20
100 / 100
87 ms5064 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 3e5 + 7; int n, m, a[N], b[N]; bool check(int mid) { int cnt = 0; for(int i = 1; i <= n; i++) { if(a[i] * m >= mid) { cnt += (a[i] * m - mid) / a[i]; } else { cnt -= (mid - a[i] * m + b[i] - 1) / b[i]; if(cnt < -inf) cnt = -inf; } } return cnt >= 0; } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> b[i], a[i] = max(a[i], b[i]); int l = 0, r = 1e18, ans = 0; while(l <= r) { int m = (l + r) >> 1; if(check(m)) { ans = m; l = m + 1; } else r = m - 1; } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:34:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:35:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...