QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#416607 | #8723. 乘二 | chenjiaqiy | RE | 1ms | 3496kb | C++17 | 1.8kb | 2024-05-22 00:10:44 | 2024-05-22 00:10:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
const double eps = 1e-8;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int n, k;
int qsm(int a, int k, int mod)
{
int res = 1;
while (k)
{
if (k & 1)
res = res * a % mod;
k >>= 1;
a = (ll)a * a % mod;
}
return res;
}
void solve()
{
vector<int> a(n + 1);
int mx = 0;
cin >> n >> k;
priority_queue<ll, vector<ll>, greater<ll>> q;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
q.push(a[i]);
mx = max(mx, a[i]);
}
while (k)
{
int x = q.top();
q.pop();
while (k && x <= q.top())
x *= 2, k--;
q.push(x);
if (q.top() >= mx)
{
while (k % n != 0)
{
k--;
int x = q.top();
q.pop();
q.push(x * 2);
}
ll sum = 0;
while (!q.empty())
{
sum += q.top();
q.pop();
sum %= mod;
}
cout << qsm(2ll, (k) / n, mod) * sum % mod << endl;
return;
}
}
ll sum = 0;
while (!q.empty())
{
sum += q.top();
q.pop();
sum %= mod;
}
cout << sum << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3496kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Runtime Error
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...