Submission #756553

# Submission time Handle Problem Language Result Execution time Memory
756553 2023-06-11T21:53:06 Z michao Self Study (JOI22_ho_t2) C++14
100 / 100
314 ms 11464 KB
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=3e5+5;
const int inf=(int)3e18+9;
int a[MAX],b[MAX];
int n,m;
int gora(int x,int y){
  if (x%y==0)return x/y;
  return x/y+1;
}
bool check(int mid){
  int balans=0;
  for (int i=1;i<=n;i++){
    int wale=max(a[i],b[i]);
    int need=gora(mid,wale);
    if (need<=m){
      balans+=m-need;
    }
    else{
      int sum=mid-wale*m;
      assert(sum>=0LL);
      int odejmij=gora(sum,b[i]);
      if (balans<-inf)return false;
      balans-=odejmij;
    }
  }
  return balans>=0;
}
int32_t main()
{
  BOOST;
  cin>>n>>m;
  for (int i=1;i<=n;i++)cin>>a[i];
  for (int i=1;i<=n;i++)cin>>b[i];
  int ans2=inf;
  if (m==1){
    for (int i=1;i<=n;i++)ans2=min(ans2,max(a[i],b[i]));
  }
  int ip=0,ik=inf;
  while (ip+1<ik){
    int mid=(ip+ik)>>1;
    if (check(mid))ip=mid;
    else ik=mid;
  }
  cout<<ip;
  return 0;
}
# 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 251 ms 5068 KB Output is correct
12 Correct 242 ms 4996 KB Output is correct
13 Correct 268 ms 5016 KB Output is correct
14 Correct 192 ms 5040 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 264 ms 5000 KB Output is correct
17 Correct 268 ms 5084 KB Output is correct
18 Correct 247 ms 5000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 264 ms 5000 KB Output is correct
3 Correct 268 ms 5084 KB Output is correct
4 Correct 247 ms 5000 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 119 ms 2584 KB Output is correct
14 Correct 81 ms 1880 KB Output is correct
15 Correct 60 ms 1492 KB Output is correct
16 Correct 50 ms 1256 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 6 ms 468 KB Output is correct
# 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 251 ms 5068 KB Output is correct
12 Correct 242 ms 4996 KB Output is correct
13 Correct 268 ms 5016 KB Output is correct
14 Correct 192 ms 5040 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 119 ms 2584 KB Output is correct
24 Correct 81 ms 1880 KB Output is correct
25 Correct 60 ms 1492 KB Output is correct
26 Correct 50 ms 1256 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 264 ms 5000 KB Output is correct
36 Correct 268 ms 5084 KB Output is correct
37 Correct 247 ms 5000 KB Output is correct
38 Correct 1 ms 328 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 324 KB Output is correct
45 Correct 5 ms 512 KB Output is correct
46 Correct 8 ms 596 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 45 ms 2128 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 1 ms 328 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 120 ms 5448 KB Output is correct
56 Correct 85 ms 3160 KB Output is correct
57 Correct 69 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 119 ms 2584 KB Output is correct
10 Correct 81 ms 1880 KB Output is correct
11 Correct 60 ms 1492 KB Output is correct
12 Correct 50 ms 1256 KB Output is correct
13 Correct 1 ms 340 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 1 ms 212 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 6 ms 468 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 264 ms 5000 KB Output is correct
22 Correct 268 ms 5084 KB Output is correct
23 Correct 247 ms 5000 KB Output is correct
24 Correct 44 ms 2032 KB Output is correct
25 Correct 120 ms 5020 KB Output is correct
26 Correct 27 ms 1364 KB Output is correct
27 Correct 241 ms 10816 KB Output is correct
28 Correct 279 ms 10808 KB Output is correct
29 Correct 254 ms 10808 KB Output is correct
30 Correct 251 ms 10812 KB Output is correct
31 Correct 273 ms 10724 KB Output is correct
32 Correct 235 ms 6116 KB Output is correct
33 Correct 314 ms 11464 KB Output is correct
34 Correct 254 ms 6172 KB Output is correct
# 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 251 ms 5068 KB Output is correct
12 Correct 242 ms 4996 KB Output is correct
13 Correct 268 ms 5016 KB Output is correct
14 Correct 192 ms 5040 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 119 ms 2584 KB Output is correct
24 Correct 81 ms 1880 KB Output is correct
25 Correct 60 ms 1492 KB Output is correct
26 Correct 50 ms 1256 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 324 KB Output is correct
41 Correct 5 ms 512 KB Output is correct
42 Correct 8 ms 596 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 45 ms 2128 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 ms 468 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 120 ms 5448 KB Output is correct
52 Correct 85 ms 3160 KB Output is correct
53 Correct 69 ms 3156 KB Output is correct
54 Correct 44 ms 2032 KB Output is correct
55 Correct 120 ms 5020 KB Output is correct
56 Correct 27 ms 1364 KB Output is correct
57 Correct 241 ms 10816 KB Output is correct
58 Correct 279 ms 10808 KB Output is correct
59 Correct 254 ms 10808 KB Output is correct
60 Correct 251 ms 10812 KB Output is correct
61 Correct 273 ms 10724 KB Output is correct
62 Correct 235 ms 6116 KB Output is correct
63 Correct 314 ms 11464 KB Output is correct
64 Correct 254 ms 6172 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 264 ms 5000 KB Output is correct
67 Correct 268 ms 5084 KB Output is correct
68 Correct 247 ms 5000 KB Output is correct
69 Correct 29 ms 1364 KB Output is correct
70 Correct 9 ms 596 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 40 ms 1812 KB Output is correct
73 Correct 9 ms 596 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 249 ms 10892 KB Output is correct
76 Correct 273 ms 10700 KB Output is correct
77 Correct 253 ms 10808 KB Output is correct
78 Correct 262 ms 10856 KB Output is correct
79 Correct 269 ms 10800 KB Output is correct
80 Correct 290 ms 10760 KB Output is correct
81 Correct 281 ms 8780 KB Output is correct
82 Correct 269 ms 8908 KB Output is correct