Submission #588068

#TimeUsernameProblemLanguageResultExecution timeMemory
588068MounirSelf Study (JOI22_ho_t2)C++14
0 / 100
1084 ms9728 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define sz(x) (int)x.size() #define pb push_back #define pii pair<int, int> #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) #define print(x) cout << #x << " est " << x << endl; #define x first #define y second #define int long long using namespace std; const int N = 1e6; int nCours, nWeeks; long double a[N], b[N]; bool isOk(int bInf){ int aAllouer = 0; for (int iCours = 0; iCours < nCours; ++iCours){ int besoin = ceil(bInf/a[iCours]); if (besoin <= nWeeks) aAllouer += nWeeks - besoin; else aAllouer -= ceil((bInf - nWeeks * a[iCours])/b[iCours]); } // cout << aAllouer return aAllouer >= 0; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> nCours >> nWeeks; for (int i = 0; i < nCours; ++i) cin >> a[i]; for (int i = 0; i < nCours; ++i){ cin >> b[i]; chmax(a[i], b[i]); } int gauche = 0, droite = nWeeks * 1e9; while (droite > gauche){ int mid = (gauche + droite)/2 + 1; if (isOk(mid)) gauche = mid; else droite = mid - 1; } cout << gauche << endl; 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...