Submission #526827

#TimeUsernameProblemLanguageResultExecution timeMemory
526827abc864197532Self Study (JOI22_ho_t2)C++17
100 / 100
323 ms7224 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define pb push_back #define eb emplace_back #define pii pair<int,int> #define X first #define Y second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void abc() {cout << endl;} template <typename T, typename ...U> void abc(T i, U ...j) { cout << i << ' ', abc(j...); } template <typename T> void printv(T l, T r) { for (; l != r; ++l) cout << *l << " \n"[l + 1 == r]; } #ifdef Doludu #define test(x...) abc("[" + string(#x) + "]", x) #define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #else #define test(x...) void(0) #define owo ios::sync_with_stdio(false), cin.tie(0); #endif const int N = 200000; int main () { owo; int n, m; cin >> n >> m; vector <int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i], a[i] = max(a[i], b[i]); auto ask = [&](lli bound) { lli rem = 0; for (int i = 0; i < n; ++i) { lli need = (bound + a[i] - 1) / a[i]; if (need <= m) rem += m - need; else rem -= (bound - 1ll * a[i] * m + b[i] - 1) / b[i]; if (rem + 1ll * m * n < 0) return false; } return rem >= 0; }; lli l = 0, r = 1ll << 60; while (r - l > 1) { (ask(l + r >> 1) ? l : r) = l + r >> 1; } cout << l << endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:51:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |   (ask(l + r >> 1) ? l : r) = l + r >> 1;
      |        ~~^~~
Main.cpp:51:33: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |   (ask(l + r >> 1) ? l : r) = l + r >> 1;
      |                               ~~^~~
#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...