QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544625 | #8723. 乘二 | shiqiaqiaya# | WA | 29ms | 6284kb | C++20 | 1.9kb | 2024-09-02 19:13:56 | 2024-09-02 19:13:58 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // 包含 tree、gp_hash_table、cc_hash_table
#include <ext/pb_ds/priority_queue.hpp> // 引入后使用 STL 的堆需要 std::
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
template<typename key, typename val = null_type, typename cmp = less<>>
using rb_tree = tree<key, val, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<typename key, typename cmp = less<>>
using pairing_heap = __gnu_pbds::priority_queue<key, cmp>;
typedef long long ll;
#define int long long
mt19937_64 rd(time(0));
const int mod = 1e9 + 7;
auto binpow = [](int a, int b, int res = 1) {
for (a %= mod; b; b >>= 1, (a *= a) %= mod) {
if (b & 1) (res *= a) %= mod;
}
return res;
};
void QAQ() {
int n, k;
cin >> n >> k;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a.begin() + 1, a.end());
int l = 0, r = k;
vector<int> ta(n + 1);
auto chk = [&](int mid) {
int sum = mid;
for (int i = 2; i <= n; i++) {
ta[i] = (a[i] - a[i - 1] + 1) / 2;
ta[i] = max<int>(0, mid - ta[i]);
sum += ta[i];
}
return sum;
};
while (l < r) {
int mid = l + r + 1 >> 1;
if (chk(mid) <= k) {
l = mid;
} else {
r = mid - 1;
}
}
int tmp = k - chk(l);
for (int i = 1; tmp; tmp--, i++) {
(a[i] *= 2) %= mod;
}
int ans = a[1] * binpow(2, l) % mod;
for (int i = 2; i <= n; i++) {
(ans += a[i] * binpow(2, ta[i]) % mod) %= mod;
}
cout << ans << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) {
QAQ();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 29ms
memory: 6284kb
input:
200000 1605067 366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...
output:
777781103
result:
wrong answer 1st numbers differ - expected: '707034173', found: '777781103'