QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#69184#5177. 摩斯电码 2.0Zesty_Fox0 6ms3356kbC++201.5kb2022-12-24 23:11:522022-12-24 23:11:55

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-24 23:11:55]
  • 评测
  • 测评结果:0
  • 用时:6ms
  • 内存:3356kb
  • [2022-12-24 23:11:52]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64=long long;
using u64=unsigned long long;
using db=double;
using vi=vector<int>;
using pii=pair<int,int>;

template<typename T>
inline T read(){
    T x=0,f=0;char ch=getchar();
    while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
    while(isdigit(ch)) x=(x*10)+(ch^48),ch=getchar();
    return !f?x:-x;
}

#define rdi read<int>
#define rdi64 read<i64>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int N=1e5+10;

int n;
i64 m,v[N],a[N];

void init(){
}

namespace TEST{
    bool check(int s){
        i64 sum=s,lst=0;
        for(int i=2;i<=n;i++){
            i64 L=lst+v[i],R=L+a[i];
            i64 mi=(L*s+v[1]-1)/v[1],mx=min((R*s+v[1]-1)/v[1],m);
            if(mi>m) return false;
            i64 mxr=-1,p,c;
            for(i64 cnt=mi;cnt<=mx;cnt++){
                i64 q=min(cnt*v[1]/s,R);
                i64 r=(q*s-1)%v[1]+1;
                if(r>mxr) mxr=r,p=q,c=cnt;
            }
            lst=p-L,sum+=c-1;
        }
        return sum<=m;
    }
    void solve(){
        v[1]+=a[1]+a[n],a[1]=a[n]=0;
        int l=0,r=m;
        while(l<r){
            int mid=(l+r+1)/2;
            if(check(mid)) l=mid;
            else r=mid-1;
        }
        cout<<l<<endl;
    }
}

int main(){
#ifdef LOCAL
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
#endif
    n=rdi(),m=rdi();
    for(int i=1;i<=n;i++) v[i]=rdi();
    for(int i=1;i<=n;i++) a[i]=rdi();
    TEST::solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3212kb

input:

5 5
2 5 5 4 3
2 4 4 5 5

output:

1

result:

wrong answer 1st lines differ - expected: '2', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 10
Accepted
time: 2ms
memory: 3336kb

input:

5 38
170 62 7 129 93
39 98 2 178 110

output:

15

result:

ok single line: '15'

Test #6:

score: -10
Wrong Answer
time: 2ms
memory: 3356kb

input:

9 75
175 240 5 139 127 216 66 128 121
94 204 150 150 50 66 26 225 142

output:

15

result:

wrong answer 1st lines differ - expected: '14', found: '15'

Subtask #3:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3336kb

input:

50 340
145945353 943649879 103681368 412537460 249168929 368424447 732376003 185334999 144319344 511521494 159409847 131972188 193314434 725004712 439570846 364294834 362411427 314220847 829136416 305293003 505373341 638710304 851245152 521859350 644327541 974583375 738591681 147795709 922157319 421...

output:

2

result:

wrong answer 1st lines differ - expected: '1', found: '2'

Subtask #4:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 6ms
memory: 3220kb

input:

1000 1000
1000000000 732930495 57470406 998674942 980507254 200197125 826994891 726235561 146440304 908089621 108786784 22006340 629816450 656110319 505896602 620885446 857656443 30603288 902307001 946990065 915078227 237356805 675986931 241912445 489230924 199892606 129509547 544771174 171477200 39...

output:

4

result:

wrong answer 1st lines differ - expected: '5', found: '4'

Subtask #5:

score: 0
Time Limit Exceeded

Test #17:

score: 0
Time Limit Exceeded

input:

10000 1000000000
1000000000 9322 8270 4220 4967 6470 2768 7780 590 1436 4219 7804 8549 8916 9250 1420 5911 2115 7098 9942 4217 7430 5121 4217 395 1363 1098 3314 2058 6689 3270 6734 6663 2769 7773 5406 5705 1208 4409 6282 5593 7665 1334 6208 1138 6856 4597 2152 3666 5645 6841 1182 8469 1768 9165 4521...

output:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

100000 1000000000
1000000000 34788 73380 66152 92356 82130 69036 96709 88944 26043 93630 93922 79818 18546 43338 40621 46994 77235 61925 24567 63929 22345 8049 40400 68808 79834 10769 68961 415 75455 73445 65121 66981 39924 45321 66260 43977 81382 98200 6894 11936 10781 29304 45584 12022 26163 73225...

output:


result: