結果
| 問題 | No.3409 How Many Gift Boxes? |
| コンテスト | |
| ユーザー |
tetra4
|
| 提出日時 | 2025-12-03 19:35:12 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,066 bytes |
| 記録 | |
| コンパイル時間 | 3,121 ms |
| コンパイル使用メモリ | 290,132 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-15 23:30:40 |
| 合計ジャッジ時間 | 7,800 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 TLE * 1 -- * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using namespace atcoder;
using ll = int64_t;
using mint = modint1000000007;
constexpr ll mod = 1000000007;
int H, W;
vector<ll> A, B;
void input() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> H >> W;
A.resize(H);
for (ll i=0; i<H; ++i) cin >> A[i];
B.resize(W);
for (ll j=0; j<W; ++j) cin >> B[j];
}
void solve_min() {
unordered_map<ll, ll> a, b;
unordered_set<ll> unique;
for (ll i=0; i<H; ++i) {
++a[A[i]];
unique.insert(A[i]);
}
for (ll j=0; j<W; ++j) {
++b[B[j]];
unique.insert(B[j]);
}
mint ans = 0;
for (ll h : unique) {
ans += h * max(a[h], b[h]);
}
cout << ans.val() << "\n";
}
void solve_max_tle() {
int ans = 0;
for (int i=0; i<H; ++i) {
for (int j=0; j<W; ++j) {
ans += min(A[i], B[j]);
}
ans %= mod;
}
cout << ans << "\n";
}
int main() {
input();
solve_min();
solve_max_tle();
return 0;
}
tetra4