Submission #1277600

#TimeUsernameProblemLanguageResultExecution timeMemory
1277600wedonttalkanymoreSelf Study (JOI22_ho_t2)C++20
0 / 100
55 ms2536 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19; int n, m; int a[N], b[N]; bool check(int mid) { __int128 sum = 0; __int128 total = (__int128)n * m; for (int i = 1; i <= n; i++) { int val = max(a[i], b[i]); __int128 need = ((__int128)mid + val - 1) / val; if (need <= m) { sum += need; } else { __int128 prod = (__int128)val * m; __int128 rem = (__int128)mid - prod; __int128 newneed = (rem + b[i] - 1) / b[i]; sum += (__int128)m + newneed; } if (sum > total) return false; } return sum <= total; } signed main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".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]; int l = 1, r = 1e18, ans = 0; while(l <= r) { int mid = (l + r) / 2; if (check(mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } cout << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen(".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...