QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#612613 | #6429. Let's Play Curling | laing2122 | WA | 208ms | 5100kb | C++17 | 1.7kb | 2024-10-05 12:18:03 | 2024-10-05 12:18:03 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
#define int long long
int a[N], b[N];
int n, m;
int mx = 0;
int ans = 0;
void solve()
{
cin >> n >> m;
for (int i = 0; i < n; i++)cin >> a[i];
for (int j = 0; j < m; j++)cin >> b[j];
sort(a, a + n);
sort(b, b + m);
if(a[0]>b[m-1]||a[n-1]<b[0])
{
cout<<n<<'\n';
return ;
}
ans = 0;
bool ok = 0;
if (n == m)
{
for (int i = 0; i < n; i++)
{
if (a[i] != b[i]) {
ok = 1;
break;
}
}
}
if (!ok&&n==m)
{
cout << "Impossible" << endl;
return;
}
int k = 0;
mx = 0;
int l, r;
for (l = 0, r = 0; l < n && r < n;)
{
// cout << r << ' ' << k << ' ';
// cout<<"\n";
if (a[r]>=b[k])
{
if (r < n - 1 && a[r] == a[r + 1])
while (r < n - 1 && a[r] == a[r + 1])r++;
r++;
l = r;
if(k<m-1&&b[k+1]==b[k])
while (k < m - 1 && b[k] == b[k + 1])k++;
if (k < m - 1)k++;
ans = max(ans, mx);
mx = 1;
//cout << r << ' ' << k << endl;
}
else if (a[r]<b[k])
{
//cout << r << endl;
r++;
mx++;
}
//cout << l << ' ' << r << endl;
}
if (r != l) {
if (l > 0)
ans = max(ans, r - l + 1);
else ans = max(ans, r - l);
}
cout << ans << endl;
}
signed main()
{
int T;
cin >> T;
while (T--)
{
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
3 2 2 2 3 1 4 6 5 2 5 3 7 1 7 3 4 3 1 10 1 1 7 7
output:
2 3 Impossible
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 208ms
memory: 5100kb
input:
5553 12 19 8 8 11 18 12 9 15 38 6 32 30 30 17 28 33 2 37 20 11 38 36 18 18 30 20 33 13 31 33 37 8 12 6 7 12 14 2 19 2 17 7 4 20 1 13 7 18 23 22 1 16 8 7 5 2 4 2 4 5 8 12 13 16 6 6 5 16 11 5 7 5 13 3 8 3 11 6 9 11 13 8 11 17 19 944782509 244117333 140979583 661724696 617847780 321687699 418677763 725...
output:
2 4 4 3 2 8 6 4 1 2 3 1 4 1 4 3 1 2 2 3 5 4 1 2 6 1 3 9 2 1 0 1 3 12 1 1 4 5 2 5 12 4 4 6 2 5 2 2 5 1 3 1 2 3 6 1 6 7 2 3 2 1 1 7 1 4 2 2 1 1 3 1 5 3 1 5 1 1 2 1 3 7 9 1 1 3 16 4 5 4 3 2 2 4 1 1 1 1 1 2 1 1 4 1 7 1 0 1 4 7 1 2 6 4 0 1 1 4 2 1 1 1 3 4 3 2 3 1 4 8 4 6 2 5 1 1 5 1 3 5 1 0 9 7 1 2 3 2 2...
result:
wrong answer 1st lines differ - expected: '1', found: '2'