QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#505963 | #6429. Let's Play Curling | Grunray | WA | 0ms | 3692kb | C++20 | 3.0kb | 2024-08-05 14:14:14 | 2024-08-05 14:14:15 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#define itn int
#define PII pair<int, int>
#define PLI pair<long long, int>
#define fep(i, a, b) for(int i = (a); i >= (b); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#include<bits/stdc++.h>
#include<unordered_map>
using ll = long long;
using ldou = long double;
using unll = unsigned long long;
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) { f = ch != '-'; ch = getchar(); }
while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
return f ? x : -x;
}
ll gcd(ll a, ll b) { // 最大公约数
while (b ^= a ^= b ^= a %= b)
;
return a;
}
ll lcm(ll a, ll b) { // 最小公倍数
return a / gcd(a, b) * b;
}
ll qmi(ll m, ll k, ll p) { // 快速幂
//求 m^k mod p,时间复杂度 O(logk)。
//m为底数,k为幂
ll res = 1 % p, t = m;
while (k) {
if (k & 1) res = res * t % p;
t = t * t % p;
k >>= 1;
}
return res;
}
unll qmi(unll m, unll k, unll p) { //龟速乘
ll res = 0, t = m;
while (k) {
if (k & 1) res = (res + t) % p;
k >>= 1;
t = (t << 1) % p;
}
return res;
}
////////////////////////////////////////////////////////////////////////////////
const int N = 1e5 + 50;
const int M = 2e5 + 50;
const ll INF = 0x3f3f3f3f;
const ll MODE = ll(998244353);
const double Pi = 3.1415926;
const double eps = 1e-8;
const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1,-1 };
//priority_queue<int> p;//这是一个大根堆q
//priority_queue<int, vector<int>, greater<int> >q;//这是一个小根堆q
//priority_queue<ll, vector<ll>, greater<ll> >pq; // 小根
ll n, m;
string str;
ll a[N], b[N];
set<ll>sa;
set<ll>sb;
void solve() {
cin >> n >> m;
/*rep(i, 1, n) cin >> a[i];
rep(j, 1, m) cin >> b[j];*/
ll x;
rep(i, 1, n) {
cin >> x;
//cin >> a[i];
sa.insert(x);
}
rep(i, 1, m) {
cin >> x;
sb.insert(x);
}
set<ll>::iterator it;
int pos = 1;
for (it = sa.begin(); it != sa.end(); it++) {
a[pos++] = (*it);
}
n = pos - 1;
pos = 1;
for (it = sb.begin(); it != sb.end(); it++) {
b[pos++] = (*it);
}
m = pos;
/*cout << " a ";
for (int i = 1; i <= n; i++)cout << a[i] << ' ';
cout << '\n';
cout << " b ";
for (int i = 1; i <= m; i++)cout << b[i] << ' ';
cout << '\n';*/
b[m] = INF;
ll res = 0;
ll l, r;
ll mid;
rep(i, 1, m) {
l = upper_bound(a + 1, a + n + 1, b[i - 1]) - a;
r = lower_bound(a + 1, a + n + 1, b[i]) - a - 1;
mid = r - l + 1;
res = max(res,mid);
}
//cout << "****** ";
if (!res) cout << "Impossible\n";
else cout << res << '\n';
sa.clear();
sb.clear();
}
signed main() {
std::ios::sync_with_stdio(false); std::cin.tie(0), std::cout.tie(0);
/*freopen("out.txt", "r", stdin);
freopen("wrt.txt", "w", stdout);*/
int TTT = 1; cin >> TTT;
while (TTT--) {
solve();
}
/*while (cin >> n >> m) {
solve();
}*/
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3692kb
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 2 Impossible
result:
wrong answer 2nd lines differ - expected: '3', found: '2'