Submission #916025

# Submission time Handle Problem Language Result Execution time Memory
916025 2024-01-25T07:09:07 Z yeediot Self Study (JOI22_ho_t2) C++14
0 / 100
449 ms 10676 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;
    }
    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((long double)mm/v[i].F);
                    left+=m-x;
                }
                else{
                    int cur=mm;
                    cur-=m*v[i].F;
                    int x=ceil((long double)cur/v[i].S);
                    left-=x;
                }
            }
            else{
                left+=m;
                int x=ceil((long double)mm/v[i].S);
                left-=x;
            }
        }
        if(left>=0){
            l=mm;
        }
        else{
            r=mm-1;
        }
    }
    cout<<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 0 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 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 7 ms 656 KB Output is correct
11 Correct 444 ms 9204 KB Output is correct
12 Correct 449 ms 10676 KB Output is correct
13 Correct 97 ms 8656 KB Output is correct
14 Incorrect 97 ms 10484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 95 ms 5376 KB Output is correct
10 Correct 57 ms 2516 KB Output is correct
11 Correct 38 ms 2520 KB Output is correct
12 Correct 44 ms 1696 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 2 ms 604 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 7 ms 656 KB Output is correct
11 Correct 444 ms 9204 KB Output is correct
12 Correct 449 ms 10676 KB Output is correct
13 Correct 97 ms 8656 KB Output is correct
14 Incorrect 97 ms 10484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 95 ms 5376 KB Output is correct
10 Correct 57 ms 2516 KB Output is correct
11 Correct 38 ms 2520 KB Output is correct
12 Correct 44 ms 1696 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 2 ms 604 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 7 ms 656 KB Output is correct
11 Correct 444 ms 9204 KB Output is correct
12 Correct 449 ms 10676 KB Output is correct
13 Correct 97 ms 8656 KB Output is correct
14 Incorrect 97 ms 10484 KB Output isn't correct
15 Halted 0 ms 0 KB -