QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#132432 | #5177. 摩斯电码 2.0 | xuqin | 0 | 1ms | 1892kb | C++14 | 1.6kb | 2023-07-29 21:53:02 | 2023-07-29 21:53:05 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<random>
#include<chrono>
#include<bitset>
#include<queue>
#include<cstdlib>
#include<cmath>
using namespace std;
const int maxn=1e5+10, inf=2e9, P=1000026113;
const double eps=1e-10;
typedef long long LL;
typedef unsigned long long ULL;
const LL INF=4e18;
typedef pair<LL, int> pli;
typedef pair<int, int> pii;
inline int read() {
int x=0, f=1; char c=getchar();
for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=0;
for(; c>='0'&&c<='9'; c=getchar()) x=x*10+c-'0';
return f?x:-x;
}
int a[maxn], v[maxn];
int f[60][510];
int main() {
int n=read(), m=read();
for(int i=1; i<=n; ++i) v[i]=read();
int mxa=0;
for(int i=1; i<=n; ++i) a[i]=read(), mxa=max(mxa, a[i]);
int l=0, r=m, b1=v[1]+a[1]+a[n];
while(l<r) {
int mid=(l+r+1)>>1;
for(int i=1; i<=n; ++i)
for(int j=0; j<=m-mid; ++j) f[i][j]=inf;
f[1][0]=0;
for(int i=1; i<n-1; ++i)
for(int j=0; j<=m-mid; ++j) {
int cur=f[i][j];
if(cur==inf) continue;
for(int k=j+((cur+v[i+1])*mid+b1-1)/b1-1; k<=m-mid; ++k) {//use j-k
int tmp=min((b1*(k-j+1)/mid)-v[i+1]-cur+1, a[i+1]);
if((1LL*(v[i+1]+cur+tmp)*mid+b1-1)/b1-1==k-j)
f[i+1][k]=min(f[i+1][k], a[i+1]-tmp);
}
}
// for(int i=1; i<n; ++i)
// for(int j=0; j<=m-mid; ++j) printf("f[%d][%d]=%d\n", i, j, f[i][j]);
int fl=0;
for(int i=0; i<=m-mid; ++i)
if(f[n-1][i]!=inf&&i+(1LL*(f[n-1][i]+v[n])*mid+b1-1)/b1-1<=m-mid) {fl=1; break;}
// printf("%d %d\n", mid, ans);
if(fl) l=mid; else r=mid-1;
}
printf("%d\n", l);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 1760kb
input:
5 5 2 5 5 4 3 2 4 4 5 5
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 1620kb
input:
5 5 2 2 1 3 2 1 4 1 5 1
output:
1
result:
ok single line: '1'
Test #3:
score: -10
Wrong Answer
time: 0ms
memory: 1508kb
input:
5 5 4 5 1 4 3 4 5 1 2 5
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 1892kb
input:
5 38 170 62 7 129 93 39 98 2 178 110
output:
14
result:
wrong answer 1st lines differ - expected: '15', found: '14'
Subtask #3:
score: 0
Wrong Answer
Test #9:
score: 20
Accepted
time: 1ms
memory: 1636kb
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:
1
result:
ok single line: '1'
Test #10:
score: -20
Wrong Answer
time: 0ms
memory: 1628kb
input:
50 4 812930736 95702098 665441738 221300735 907249385 493535187 564488639 395538786 904638787 889168971 900357003 21636011 764504998 243769369 89695414 656445453 745884937 656421159 296885639 206987195 368396912 54679316 346974906 192974419 56304682 420269636 396600899 473826419 708845531 57105109 5...
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'
Subtask #4:
score: 0
Runtime Error
Test #13:
score: 0
Runtime Error
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:
result:
Subtask #5:
score: 0
Runtime Error
Test #17:
score: 0
Runtime Error
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
Runtime Error
Test #21:
score: 0
Runtime Error
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...