제출 #1018761

#제출 시각아이디문제언어결과실행 시간메모리
1018761vjudge1Self Study (JOI22_ho_t2)C++17
25 / 100
123 ms13932 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define tobit(n) bitset<20>(n) //выводит 20 элементов в битовую систему #define all(v) (v).begin(), (v).end() #define rtt(v, k) rotate(v.begin(), v.begin() + k, v.end()); //move k elements back vector<pair<int, int>> v; int n, m; bool check(int MID){ vector<int> cur(n, 0); int result = 0; for(int i = 0; i < n && result <= n * m; i++){ int z = max(v[i].ff, v[i].ss); int k = (MID + z - 1) / z; if(k >= m){ result += m; cur[i] = MID - m * z; result += (cur[i] + v[i].ss - 1) / v[i].ss; } else result += k; } return result <= n * m; } signed main(){ cin >> n >> m; v.assign(n, {0, 0}); for(auto &to : v) cin >> to.ff; for(auto &to : v) cin >> to.ss; int l = 0; int r = 1e18 + 6; while(r > l + 1){ int m = (l + r) / 2; if(check(m)) l = m; else r = m; } cout << l; } // NEED TO FAST CIN && COUT // const int fastIO = [](){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
#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...