Submission #916033

# Submission time Handle Problem Language Result Execution time Memory
916033 2024-01-25T07:18:47 Z yeediot Self Study (JOI22_ho_t2) C++14
62 / 100
296 ms 20156 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define all(X) X.begin(),X.end()
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#ifdef local
void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
void setio(){}
#define debug(x...)
#endif
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    setio();
    int n,m;
    cin>>n>>m;
    vector<pair<__int128,__int128>>v;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.pb({a,0});
    }
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v[i].S=a;
    }
    int l=0,r=2e18+10;
    while(l<r){
        int mm=l+r+1>>1;
        __int128 left=n*m;
        bool ok=1;
        for(int i=0;i<n;i++){
            if(v[i].F>=v[i].S){
                if(v[i].F*m>mm){
                    __int128 x=ceil((double)mm/v[i].F);
                    left-=x;
                }
                else{
                    __int128 cur=mm;
                    left-=m;
                    cur-=m*v[i].F;
                    __int128 x=ceil((double)cur/v[i].S);
                    left-=x;
                }
            }
            else{
                __int128 x=ceil((double)mm/v[i].S);
                left-=x;
            }
        }
        if(left>=0){
            l=mm;
        }
        else{
            r=mm-1;
        }
    }
    cout<<(int)l<<'\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:37:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |         int mm=l+r+1>>1;
      |                ~~~^~
Main.cpp:39:14: warning: unused variable 'ok' [-Wunused-variable]
   39 |         bool ok=1;
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 860 KB Output is correct
11 Correct 282 ms 19904 KB Output is correct
12 Correct 273 ms 19844 KB Output is correct
13 Correct 214 ms 17852 KB Output is correct
14 Correct 241 ms 19908 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 259 ms 18948 KB Output is correct
17 Correct 265 ms 19844 KB Output is correct
18 Correct 253 ms 20156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 259 ms 18948 KB Output is correct
3 Correct 265 ms 19844 KB Output is correct
4 Correct 253 ms 20156 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 131 ms 11464 KB Output is correct
14 Correct 88 ms 6128 KB Output is correct
15 Correct 66 ms 5320 KB Output is correct
16 Correct 53 ms 3280 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 4 ms 724 KB Output is correct
23 Correct 5 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 860 KB Output is correct
11 Correct 282 ms 19904 KB Output is correct
12 Correct 273 ms 19844 KB Output is correct
13 Correct 214 ms 17852 KB Output is correct
14 Correct 241 ms 19908 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 131 ms 11464 KB Output is correct
24 Correct 88 ms 6128 KB Output is correct
25 Correct 66 ms 5320 KB Output is correct
26 Correct 53 ms 3280 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 856 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 259 ms 18948 KB Output is correct
36 Correct 265 ms 19844 KB Output is correct
37 Correct 253 ms 20156 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 6 ms 856 KB Output is correct
46 Correct 9 ms 1248 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 48 ms 3032 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 5 ms 860 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 136 ms 11032 KB Output is correct
56 Correct 69 ms 6100 KB Output is correct
57 Correct 105 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 131 ms 11464 KB Output is correct
10 Correct 88 ms 6128 KB Output is correct
11 Correct 66 ms 5320 KB Output is correct
12 Correct 53 ms 3280 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 4 ms 724 KB Output is correct
19 Correct 5 ms 856 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 259 ms 18948 KB Output is correct
22 Correct 265 ms 19844 KB Output is correct
23 Correct 253 ms 20156 KB Output is correct
24 Correct 51 ms 2772 KB Output is correct
25 Correct 116 ms 10692 KB Output is correct
26 Correct 30 ms 2124 KB Output is correct
27 Correct 257 ms 19388 KB Output is correct
28 Correct 271 ms 19124 KB Output is correct
29 Correct 255 ms 19928 KB Output is correct
30 Correct 260 ms 18876 KB Output is correct
31 Incorrect 296 ms 19344 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 860 KB Output is correct
11 Correct 282 ms 19904 KB Output is correct
12 Correct 273 ms 19844 KB Output is correct
13 Correct 214 ms 17852 KB Output is correct
14 Correct 241 ms 19908 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 131 ms 11464 KB Output is correct
24 Correct 88 ms 6128 KB Output is correct
25 Correct 66 ms 5320 KB Output is correct
26 Correct 53 ms 3280 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 4 ms 724 KB Output is correct
33 Correct 5 ms 856 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 6 ms 856 KB Output is correct
42 Correct 9 ms 1248 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 48 ms 3032 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 5 ms 860 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 136 ms 11032 KB Output is correct
52 Correct 69 ms 6100 KB Output is correct
53 Correct 105 ms 6612 KB Output is correct
54 Correct 51 ms 2772 KB Output is correct
55 Correct 116 ms 10692 KB Output is correct
56 Correct 30 ms 2124 KB Output is correct
57 Correct 257 ms 19388 KB Output is correct
58 Correct 271 ms 19124 KB Output is correct
59 Correct 255 ms 19928 KB Output is correct
60 Correct 260 ms 18876 KB Output is correct
61 Incorrect 296 ms 19344 KB Output isn't correct
62 Halted 0 ms 0 KB -