답안 #534085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534085 2022-03-08T00:42:37 Z browntoad Self Study (JOI22_ho_t2) C++14
100 / 100
325 ms 5968 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define pdd pair<double ,double>
#define pcc pair<char, char> 
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif

const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=4e5+5;
const double PI=acos(-1);
std::ostream&
operator<<( std::ostream& dest, __int128_t value )
{
    std::ostream::sentry s( dest );
    if ( s ) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[ 128 ];
        char* d = std::end( buffer );
        do
        {
            -- d;
            *d = "0123456789"[ tmp % 10 ];
            tmp /= 10;
        } while ( tmp != 0 );
        if ( value < 0 ) {
            -- d;
            *d = '-';
        }
        int len = std::end( buffer ) - d;
        if ( dest.rdbuf()->sputn( d, len ) != len ) {
            dest.setstate( std::ios_base::badbit );
        }
    }
    return dest;
}
ll pw(ll x, ll p, ll m=mod){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}

ll inv(ll a, ll m=mod){
    return pw(a,m-2);
}

//=======================================================================================


signed main (){
    IOS();
    int n,m; cin>>n>>m;
    vector<int> a(n), b(n);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n){
        cin>>b[i];
    }
    __int128 l=0, r=3;
    REP(i,23){
        r*=10;
    }
    //cout<<r<<endl;
    while(l<=r){
        //cout<<l<<' '<<r<<endl;
        if (l==r){
            cout<<l<<endl;
            break;
        }
        __int128 mid=(l+r+1)/2;
        __int128 debt=0;
        REP(i,n){
            if (max(a[i], b[i])*m>=mid){
                __int128 tot=mid/max(a[i], b[i])+(mid%max(a[i], b[i])>0);
                debt-=m-tot;
            }
            else {
                __int128 mx=mid;
                mx-=max(a[i], b[i])*m;
                debt+=mx/b[i]+(mx%b[i]>0);
            }
        }
        if (debt>0){
            r=mid-1;
        }
        else l=mid;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 241 ms 5004 KB Output is correct
12 Correct 258 ms 5004 KB Output is correct
13 Correct 239 ms 4940 KB Output is correct
14 Correct 320 ms 4940 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 308 ms 5020 KB Output is correct
17 Correct 255 ms 4940 KB Output is correct
18 Correct 241 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 308 ms 5020 KB Output is correct
3 Correct 255 ms 4940 KB Output is correct
4 Correct 241 ms 4940 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 122 ms 2636 KB Output is correct
14 Correct 84 ms 1872 KB Output is correct
15 Correct 64 ms 1484 KB Output is correct
16 Correct 54 ms 1252 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 5 ms 332 KB Output is correct
23 Correct 5 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 241 ms 5004 KB Output is correct
12 Correct 258 ms 5004 KB Output is correct
13 Correct 239 ms 4940 KB Output is correct
14 Correct 320 ms 4940 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 122 ms 2636 KB Output is correct
24 Correct 84 ms 1872 KB Output is correct
25 Correct 64 ms 1484 KB Output is correct
26 Correct 54 ms 1252 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 5 ms 332 KB Output is correct
33 Correct 5 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 308 ms 5020 KB Output is correct
36 Correct 255 ms 4940 KB Output is correct
37 Correct 241 ms 4940 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 5 ms 332 KB Output is correct
46 Correct 10 ms 332 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 44 ms 1232 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 4 ms 332 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 131 ms 2636 KB Output is correct
56 Correct 78 ms 1868 KB Output is correct
57 Correct 110 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 122 ms 2636 KB Output is correct
10 Correct 84 ms 1872 KB Output is correct
11 Correct 64 ms 1484 KB Output is correct
12 Correct 54 ms 1252 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 5 ms 332 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 308 ms 5020 KB Output is correct
22 Correct 255 ms 4940 KB Output is correct
23 Correct 241 ms 4940 KB Output is correct
24 Correct 42 ms 972 KB Output is correct
25 Correct 129 ms 2380 KB Output is correct
26 Correct 29 ms 716 KB Output is correct
27 Correct 240 ms 4940 KB Output is correct
28 Correct 273 ms 5000 KB Output is correct
29 Correct 249 ms 4940 KB Output is correct
30 Correct 264 ms 5060 KB Output is correct
31 Correct 277 ms 5004 KB Output is correct
32 Correct 314 ms 5008 KB Output is correct
33 Correct 281 ms 5004 KB Output is correct
34 Correct 312 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 241 ms 5004 KB Output is correct
12 Correct 258 ms 5004 KB Output is correct
13 Correct 239 ms 4940 KB Output is correct
14 Correct 320 ms 4940 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 122 ms 2636 KB Output is correct
24 Correct 84 ms 1872 KB Output is correct
25 Correct 64 ms 1484 KB Output is correct
26 Correct 54 ms 1252 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 5 ms 332 KB Output is correct
33 Correct 5 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 5 ms 332 KB Output is correct
42 Correct 10 ms 332 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 44 ms 1232 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 131 ms 2636 KB Output is correct
52 Correct 78 ms 1868 KB Output is correct
53 Correct 110 ms 1876 KB Output is correct
54 Correct 42 ms 972 KB Output is correct
55 Correct 129 ms 2380 KB Output is correct
56 Correct 29 ms 716 KB Output is correct
57 Correct 240 ms 4940 KB Output is correct
58 Correct 273 ms 5000 KB Output is correct
59 Correct 249 ms 4940 KB Output is correct
60 Correct 264 ms 5060 KB Output is correct
61 Correct 277 ms 5004 KB Output is correct
62 Correct 314 ms 5008 KB Output is correct
63 Correct 281 ms 5004 KB Output is correct
64 Correct 312 ms 5968 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 308 ms 5020 KB Output is correct
67 Correct 255 ms 4940 KB Output is correct
68 Correct 241 ms 4940 KB Output is correct
69 Correct 30 ms 1468 KB Output is correct
70 Correct 9 ms 588 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 46 ms 1732 KB Output is correct
73 Correct 10 ms 584 KB Output is correct
74 Correct 1 ms 244 KB Output is correct
75 Correct 261 ms 5864 KB Output is correct
76 Correct 257 ms 5964 KB Output is correct
77 Correct 268 ms 5940 KB Output is correct
78 Correct 294 ms 5912 KB Output is correct
79 Correct 303 ms 5960 KB Output is correct
80 Correct 285 ms 5912 KB Output is correct
81 Correct 275 ms 5944 KB Output is correct
82 Correct 325 ms 5960 KB Output is correct