답안 #916023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916023 2024-01-25T07:00:15 Z yeediot Self Study (JOI22_ho_t2) C++14
35 / 100
124 ms 12600 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<pii>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;
    }
    sort(all(v),greater<>());
    int l=0,r=(int)1e18+10;
    while(l<r){
        int mm=l+r+1>>1;
        int left=0;
        bool ok=1;
        for(int i=0;i<n;i++){
            if(v[i].F>=v[i].S){
                if(v[i].F*m>mm){
                    int x=ceil((double)mm/v[i].F);
                    left+=m-x;
                }
                else{
                    int cur=mm;
                    cur-=m*v[i].F;
                    int x=ceil((double)cur/v[i].S);
                    left-=x;
                    if(left<0){
                        ok=0;
                        break;
                    }
                }
            }
            else{
                left+=m;
                int x=ceil((double)mm/v[i].S);
                left-=x;
                if(left<0){
                    ok=0;
                    break;
                }
            }
        }
        if(ok){
            l=mm;
        }
        else{
            r=mm-1;
        }
    }
    cout<<l<<'\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:38:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |         int mm=l+r+1>>1;
      |                ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 124 ms 11556 KB Output is correct
12 Correct 124 ms 11440 KB Output is correct
13 Correct 69 ms 10472 KB Output is correct
14 Correct 54 ms 11844 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 42 ms 10944 KB Output is correct
17 Correct 71 ms 11784 KB Output is correct
18 Correct 94 ms 12332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 42 ms 10944 KB Output is correct
3 Correct 71 ms 11784 KB Output is correct
4 Correct 94 ms 12332 KB Output is correct
5 Correct 1 ms 448 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 65 ms 6196 KB Output is correct
14 Correct 33 ms 3288 KB Output is correct
15 Correct 35 ms 3444 KB Output is correct
16 Correct 23 ms 2240 KB Output is correct
17 Correct 1 ms 468 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 1 ms 456 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 124 ms 11556 KB Output is correct
12 Correct 124 ms 11440 KB Output is correct
13 Correct 69 ms 10472 KB Output is correct
14 Correct 54 ms 11844 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 65 ms 6196 KB Output is correct
24 Correct 33 ms 3288 KB Output is correct
25 Correct 35 ms 3444 KB Output is correct
26 Correct 23 ms 2240 KB Output is correct
27 Correct 1 ms 468 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 1 ms 456 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 42 ms 10944 KB Output is correct
36 Correct 71 ms 11784 KB Output is correct
37 Correct 94 ms 12332 KB Output is correct
38 Correct 1 ms 496 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 456 KB Output is correct
41 Incorrect 1 ms 344 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 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 65 ms 6196 KB Output is correct
10 Correct 33 ms 3288 KB Output is correct
11 Correct 35 ms 3444 KB Output is correct
12 Correct 23 ms 2240 KB Output is correct
13 Correct 1 ms 468 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 1 ms 456 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 42 ms 10944 KB Output is correct
22 Correct 71 ms 11784 KB Output is correct
23 Correct 94 ms 12332 KB Output is correct
24 Correct 18 ms 2012 KB Output is correct
25 Correct 52 ms 7140 KB Output is correct
26 Correct 13 ms 1672 KB Output is correct
27 Correct 118 ms 12112 KB Output is correct
28 Correct 118 ms 10948 KB Output is correct
29 Correct 98 ms 12600 KB Output is correct
30 Correct 108 ms 11524 KB Output is correct
31 Incorrect 123 ms 11444 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 124 ms 11556 KB Output is correct
12 Correct 124 ms 11440 KB Output is correct
13 Correct 69 ms 10472 KB Output is correct
14 Correct 54 ms 11844 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 65 ms 6196 KB Output is correct
24 Correct 33 ms 3288 KB Output is correct
25 Correct 35 ms 3444 KB Output is correct
26 Correct 23 ms 2240 KB Output is correct
27 Correct 1 ms 468 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 1 ms 456 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 496 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 456 KB Output is correct
37 Incorrect 1 ms 344 KB Output isn't correct
38 Halted 0 ms 0 KB -