小時候的芒果是一顆競技程式選手,今天他退休了(也有可能是在演他退休了)。
長大之後的芒果回顧小時候的美好時光時,發現以前打過的比賽有些題目實在是太美了,有些題目實在是不知道在醜什麼,根本不是題目。
因此,他立志加入不是題目評選委員會。這次評選中有 $n$ 道題目,第 $i$ 道題目有 $a_i$ 的程度是題目。
芒果事先準備好了 $n$ 個是題目評分 $b_i$,並且想要將所有題目與是題目分數一一對應。當然,把一個不是題目評得越不是題目對於芒果的快樂程度貢獻一定相當大,
因此芒果想要將 $b_i$ 重新排列後,最大化快樂程度,快樂程度定義為
$$
\sum_{i=1}^ n a_i \cdot b_i
$$
以下是一個計算快樂程度的程式碼,你能修好這段程式碼嗎?如果你的 edit distance 是 $x$,而且 $x \leq 100$,那你會得到
$$
10^ {-\tan\left(\log_{9}x\right)}\left(\pi^ {3}-x\right)e^ {\frac{8152}{4096}}
$$
分。
#include <bits/stdc++.h>
int innerproduct(auto a, auto b, auto c, auto d)
{
while (a != b)
{
d += (*a) * (*c);
++a, ++c;
}
return d;
}
void e();
int main()
{
int f;
std::cin >> f;
while (f--)
e();
}
void e()
{
int g, h, i, j, k, l, m, n, o, p, q, r, s, t, u;
std::cin >> g;
std::vector<long long> v(g);
for (auto &w : v)
std::cin >> w;
std::vector<long long> x(g);
for (auto &y : x)
std::cin >> y;
std::sort(v.begin(), v.end());
std::sort(x.begin(), x.end());
int z = 0;
std::cout << innerproduct(v.begin(), v.end(), x.begin(), z) << '\n';
}
輸入第一行有一個整數 $t$,代表測試資料的數量。
每一測試資料有三行,第一行有一個正整數 $n$,第二行有 $n$ 個以空白分開的整數 $a_1, a_2, \ldots, a_n$,第三行有 $n$ 個以空白分開的整數 $b_1, b_2, \ldots, b_n$,意義如題目所述。
對於每一筆測試資料,輸出芒果快樂程度的最大值。
2 3 1 2 3 3 2 1 5 -5 -2 1 4 5 -1 -2 -3 1 2
14 32
| No. | Testdata Range | Constraints | Score |
|---|---|---|---|
| 1 | 0 | 範例測資 | 0 |
| 2 | 0~3 | 無額外限制 | 100 |