# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703648 |
2023-02-28T03:14:21 Z |
niter |
Self Study (JOI22_ho_t2) |
C++14 |
|
361 ms |
7376 KB |
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<long long,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n";
using namespace std;
long long a[300050], b[300050], c[300050];
/*ostream& operator<<(ostream &os, pii XXX){
cout << "[" << XXX.ff << ", " << XXX.ss << "]";
}*/
void db(){
cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
cout << XXX; db(YYY...);
}
int main(){
long long n, m, all;
cin >> n >> m;
all = n * m;
loop(i,0,n) cin >> a[i];
loop(i,0,n) cin >> b[i];
loop(i,0,n) c[i] = max(a[i], b[i]);
long long Tr = 1, Fal = (long long)(9e18), mid;
long long cost, classes;
while(Fal - Tr > 1){
mid = (Tr + Fal) >> 1;
classes = 0;
loop(i,0,n){
cost = mid;
if(b[i] >= a[i]){
classes += ((cost-1) / b[i] + 1);
}
else{
classes += min(((cost-1) / a[i] + 1), m);
cost -= min(((cost-1) / a[i] + 1), m) * a[i];
if(cost > 0)
classes += ((cost-1) / b[i] + 1);
}
}
if(classes > all){
Fal = mid;
}
else{
Tr = mid;
}
}
cout << Tr << "\n";
return 0;
}
/*
3 3
19 4 5
2 6 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
340 KB |
Output is correct |
11 |
Correct |
361 ms |
7376 KB |
Output is correct |
12 |
Correct |
356 ms |
7252 KB |
Output is correct |
13 |
Correct |
268 ms |
7292 KB |
Output is correct |
14 |
Incorrect |
160 ms |
7268 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
170 ms |
3756 KB |
Output is correct |
10 |
Correct |
116 ms |
2640 KB |
Output is correct |
11 |
Correct |
82 ms |
2060 KB |
Output is correct |
12 |
Correct |
75 ms |
1704 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
340 KB |
Output is correct |
11 |
Correct |
361 ms |
7376 KB |
Output is correct |
12 |
Correct |
356 ms |
7252 KB |
Output is correct |
13 |
Correct |
268 ms |
7292 KB |
Output is correct |
14 |
Incorrect |
160 ms |
7268 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
170 ms |
3756 KB |
Output is correct |
10 |
Correct |
116 ms |
2640 KB |
Output is correct |
11 |
Correct |
82 ms |
2060 KB |
Output is correct |
12 |
Correct |
75 ms |
1704 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
340 KB |
Output is correct |
11 |
Correct |
361 ms |
7376 KB |
Output is correct |
12 |
Correct |
356 ms |
7252 KB |
Output is correct |
13 |
Correct |
268 ms |
7292 KB |
Output is correct |
14 |
Incorrect |
160 ms |
7268 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |