比赛 |
4043级NOIP2022欢乐赛6th |
评测结果 |
TTTTTTTTTTTTWTTTTTTT |
题目名称 |
屠龙勇士 |
最终得分 |
0 |
用户昵称 |
HeSn |
运行时间 |
39.644 s |
代码语言 |
C++ |
内存使用 |
24.81 MiB |
提交时间 |
2022-11-18 19:34:15 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 500010;
int n, m, a[MAXN], b[MAXN], p[MAXN], cs[MAXN], vis[MAXN];
signed main() {
freopen("2018dragon.in", "r", stdin);
freopen("2018dragon.out", "w", stdout);
int t;
cin >> t;
for(int tt = 1; tt <= t; tt ++) {
cin >> n >> m;
memset(vis, 0, sizeof(vis));
for(int i = 1; i <= n; i ++) {
cin >> a[i];
}
for(int i = 1; i <= n; i ++) {
cin >> p[i];
}
for(int i = 1; i <= n; i ++) {
cin >> b[m + i];
vis[b[m + i]] ++;
}
for(int i = 1; i <= m; i ++) {
cin >> b[i];
vis[b[i]] ++;
}
for(int i = 1; i <= n; i ++) {
sort(b + 1, b + n + i);
int x;
for(int j = m + i - 1; j >= 1; j --) {
if(vis[b[j]]) {
cs[i] = b[j];
if(a[i] >= b[j]) {
cs[i] = b[j];
break;
}
}
}
// cout << ' ' << cs[i];
vis[cs[i]] --;
}
// cout << endl;
for(int k = 1; k; k ++) {
int flg = 1;
for(int i = 1; i <= n; i ++) {
int x = a[i] - k * cs[i];
if(x * p[i] > 0 || abs(x) % abs(p[i]) != 0) {
flg = 0;
break;
}
}
if(flg) {
cout << k << endl;
break;
}
}
}
return 0;
}