QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#132270 | #5177. 摩斯电码 2.0 | xuqin | 0 | 12ms | 5332kb | C++14 | 1.7kb | 2023-07-29 11:44:57 | 2023-07-29 11:44:58 |
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=1e9, P=1e9+7;
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;
}
mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count());
int n, m, a[maxn], v[maxn], cho[maxn];
int s[maxn]; LL b[maxn];
int calc() {
for(int i=1; i<=n; ++i) b[i]=a[i];
for(int i=1; i<=n; ++i) b[i]+=cho[i], b[i%n+1]+=a[i]-cho[i];
int l=0, r=m;
while(l<r) {
int mid=(l+r+1)>>1;
//can 1 get mid
LL oth=0;
for(int i=2; i<=n; ++i) {
//how many x: b[i]/x > b[1]/mid
//b[i]*mid/b[1] > x
oth+=(1LL*b[i]*mid+b[1]-1)/b[1]-1;
if(oth>1LL*m) break;
}
if(oth+mid<=1LL*m) l=mid; else r=mid-1;
}
return l;
}
int main() {
int st=clock();
n=read(), m=read();
for(int i=1; i<=n; ++i) v[i]=read();
for(int i=1; i<=n; ++i) a[i]=read();
for(int i=1; i<n; ++i) cho[i]=a[i]; cho[n]=0;
int ans=calc();
double T=1.0;
while(clock()-st<900) {
int x=rnd()%n+1, nw=rnd()%(a[x]+1);
int pre=cho[x]; cho[x]=nw;
int nxt=calc();
if(nxt>=ans) ans=nxt;
else {
int t=rnd()%100001;
if(t/100000.0<exp(-(1.0*ans-nxt)/T)) {
ans=nxt;
} else {
cho[x]=pre;
}
}
T*=0.999;
}
printf("%d", ans);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5332kb
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: 0
Wrong Answer
time: 2ms
memory: 3280kb
input:
5 38 170 62 7 129 93 39 98 2 178 110
output:
8
result:
wrong answer 1st lines differ - expected: '15', found: '8'
Subtask #3:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 2ms
memory: 3116kb
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:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 1ms
memory: 3184kb
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
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 0ms
memory: 3340kb
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:
952535563
result:
wrong answer 1st lines differ - expected: '952514052', found: '952535563'
Subtask #6:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 12ms
memory: 5156kb
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:
166936193
result:
wrong answer 1st lines differ - expected: '166625645', found: '166936193'