結果
| 問題 | No.3436 [Cherry 8th Tune B] この夏に何が起こるかな? |
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2026-01-24 03:42:15 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 594 ms / 4,000 ms |
| コード長 | 2,604 bytes |
| 記録 | |
| コンパイル時間 | 4,862 ms |
| コンパイル使用メモリ | 365,728 KB |
| 実行使用メモリ | 25,088 KB |
| 最終ジャッジ日時 | 2026-01-24 03:47:24 |
| 合計ジャッジ時間 | 309,334 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template <class T, class F>
T binarySearch(T ok, T ng, const F &f) {
while (abs(ok - ng) > 1) {
T mid = (ok + ng) / 2;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
void solve() {
int n, m, k; cin >> n >> m >> k;
long long p; cin >> p;
vector<int>t(n);
rep(i, n)cin >> t[i];
vector<int>c(n);
rep(i, n)cin >> c[i], c[i]--;
vector col(k, vector<int>());
vector<int>b(m);
rep(i, m)cin >> b[i];
vector<int>d(m);
rep(i, m)cin >> d[i], d[i]--;
rep(i, m) col[d[i]].push_back(b[i]);
rep(i, k)sort(all(col[i]));
auto sb = b;
sort(all(sb));
vector<int>s(k);
rep(i, k)cin >> s[i];
// 価格がtarget以下の個数がp以下
auto f = [&](const long long target)->bool {
long long cnt = 0;
rep(i, n) {
int tmp = 0;
// all
tmp += upper_bound(all(sb), target - t[i]) - sb.begin();
// same coler
tmp -= upper_bound(all(col[c[i]]), target - t[i]) - col[c[i]].begin();
// same coler2
tmp += upper_bound(all(col[c[i]]), target - t[i] + s[c[i]]) - col[c[i]].begin();
cnt += tmp;
}
return cnt <= p - 1;
};
auto pri = binarySearch<long long>(0, 2 * INF + 10, f) + 1;
// cout << "p " << pri << endl;
// col,val,idx
map<P, int>mp;
// val,col
map<int, set<int>>mp2;
rep(i, m) {
mp[{d[i], b[i]}] = i;
mp2[b[i]].insert(d[i]);
}
rep(i, n) {
{
// not same
int x = pri - t[i];
for (auto e : mp2[x]) {
if (e == c[i])continue;
auto ans2 = mp[{e, x}];
cout << i + 1 << " " << ans2 + 1 << endl;
return;
}
}
{
// same
int x = pri - t[i] + s[c[i]];
if (mp.count({ c[i],x })) {
cout << i + 1 << " " << mp[{c[i], x}] + 1 << endl;
return;
}
}
}
cout << "NG" << endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int q; cin >> q;
while (q--)solve();
return 0;
}
kwm_t