結果
| 問題 | No.3436 [Cherry 8th Tune B] この夏に何が起こるかな? |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2026-01-23 22:06:07 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,719 bytes |
| 記録 | |
| コンパイル時間 | 5,118 ms |
| コンパイル使用メモリ | 367,792 KB |
| 実行使用メモリ | 27,736 KB |
| 最終ジャッジ日時 | 2026-01-23 22:08:12 |
| 合計ジャッジ時間 | 19,095 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 20 RE * 18 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n, m, k;
ll p;
cin >> n >> m >> k >> p;
p--;
VL t(n), c(n), b(m), d(m), s(k);
rep(i, n) cin >> t[i];
rep(i, n) cin >> c[i], c[i]--;
rep(i, m) cin >> b[i];
rep(i, m) cin >> d[i], d[i]--;
rep(i, k) cin >> s[i];
VL tall = t, ball = b;
sort(all(tall));
sort(all(ball));
VVL tc(k), bc(k);
rep(i, n) tc[c[i]].emplace_back(t[i]);
rep(i, m) bc[d[i]].emplace_back(b[i]);
auto get_cnt = [](const VL& a, const VL& b, ll v) -> ll {
int n = a.size(), m = b.size();
int j = m;
ll res = 0;
for (ll x : a) {
while (j && x + b[j-1] >= v) j--;
res += j;
}
return res;
};
ll l = 0, r = 2001001001;
while (r - l > 1) {
ll c = (l + r) / 2;
ll cnt = 0;
cnt += get_cnt(tall, ball, c);
rep(i, k) {
cnt -= get_cnt(tc[i], bc[i], c);
cnt += get_cnt(tc[i], bc[i], c + s[i]);
}
(cnt <= p ? l : r) = c;
}
VVI c2i(k), d2j(k);
rep(i, n) c2i[c[i]].emplace_back(i);
rep(j, m) d2j[d[j]].emplace_back(j);
multiset<pair<ll, int>> st0, st1;
rep(i, n) st0.emplace(t[i], i);
int ans_i = -1, ans_j = -1;
rep(col, k) {
st1.clear();
for (int i : c2i[col]) {
st0.erase({t[i], i});
st1.emplace(t[i], i);
}
for (int j : d2j[col]) {
auto it = st0.lower_bound({l - b[j], -1});
if (it != st0.end() && it->first == l - b[j]) {
ans_i = it->second, ans_j = j;
break;
}
it = st1.lower_bound({l - b[j] + s[col], -1});
if (it != st1.end() && it->first == l - b[j] + s[col]) {
ans_i = it->second, ans_j = j;
break;
}
}
if (ans_i != -1) break;
for (int i : c2i[col]) st0.emplace(t[i], i);
}
assert(ans_i != -1);
cout << ans_i + 1 << ' ' << ans_j + 1 << '\n';
}
}
Kude