# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
576236 | 2022-06-12T16:45:05 Z | Aldas25 | Self Study (JOI22_ho_t2) | C++14 | 457 ms | 5104 KB |
/* //#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") */ #include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long double ld; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 500100, MAXK = 20; const ll INF = 1e14; //const ll MOD = 1e9+7; const ll MOD = 998244353; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } ll n, m; ll a[MAXN], b[MAXN]; bool check (ll x) { ll needLessons = 0; FOR(i, 1, n) { ll w1 = (x + a[i] - 1) / a[i]; ll w2 = (x-m*a[i] + b[i] - 1) / b[i]; if (w1 <= m) needLessons -= m-w1; else needLessons += w2; } return needLessons <= 0; } int main() { setIO(); cin >> n >> m; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; FOR(i, 1, n) a[i] = max(a[i], b[i]); ll le = 0, ri = 1e18; while (le < ri) { ll m = (le+ri+1)/2; if (check(m)) le = m; else ri = m-1; } cout << le << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 220 ms | 5016 KB | Output is correct |
12 | Correct | 217 ms | 4928 KB | Output is correct |
13 | Correct | 234 ms | 5020 KB | Output is correct |
14 | Incorrect | 457 ms | 5104 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 113 ms | 2692 KB | Output is correct |
10 | Correct | 74 ms | 1876 KB | Output is correct |
11 | Correct | 54 ms | 1492 KB | Output is correct |
12 | Correct | 46 ms | 1236 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Incorrect | 9 ms | 412 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 220 ms | 5016 KB | Output is correct |
12 | Correct | 217 ms | 4928 KB | Output is correct |
13 | Correct | 234 ms | 5020 KB | Output is correct |
14 | Incorrect | 457 ms | 5104 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 113 ms | 2692 KB | Output is correct |
10 | Correct | 74 ms | 1876 KB | Output is correct |
11 | Correct | 54 ms | 1492 KB | Output is correct |
12 | Correct | 46 ms | 1236 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Incorrect | 9 ms | 412 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 220 ms | 5016 KB | Output is correct |
12 | Correct | 217 ms | 4928 KB | Output is correct |
13 | Correct | 234 ms | 5020 KB | Output is correct |
14 | Incorrect | 457 ms | 5104 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |