QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725963 | #2375. Life Transfer | LaVuna47# | RE | 0ms | 3788kb | C++20 | 2.4kb | 2024-11-08 20:57:17 | 2024-11-08 20:57:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const ll INF = 1e13;
int solve()
{
ll n,k,lc,pc,lm,pm,t,d;
if (!(cin >> n>>k))
return 1;
cin >> lc >> pc >> lm >> pm >> t >> d;
vector<ll> ar(n);
FOR(i,0,n)
cin >> ar[i];
sort(rall(ar));
vector<ll> p1(n+1);
FOR(i,0,n)
p1[i+1] = max(ar[i]-lc,0ll);
FOR(i,1,n+1)
p1[i] += p1[i-1];
auto getSum1 = [&](ll l, ll r) -> ll
{
return p1[r + 1] - p1[l];
};
vector<ll> p2(n);
FOR(i,0,n){
p2[i+1] = min(ar[i]-lc,0ll);
if(p2[i+1] < -d)
p2[i+1] = -INF;
}
FOR(i,1,n+1)
p2[i] += p2[i-1];
auto getSum2 = [&](ll l, ll r) -> ll
{
return p2[r + 1] - p2[l];
};
vector<ll> p3(n);
FOR(i,0,n)
p3[i+1] = max(ar[i]-lm,0ll);
FOR(i,1,n+1)
p3[i] += p3[i-1];
auto getSum3 = [&](ll l, ll r) -> ll
{
return p3[r + 1] - p3[l];
};
vector<ll> p4(n);
FOR(i,0,n){
p4[i+1] = min(ar[i]-lm,0ll);
if(p4[i+1] < -d)
p4[i+1] = -INF;
}
FOR(i,1,n+1)
p4[i] += p4[i-1];
auto getSum4 = [&](ll l, ll r) -> ll
{
return p4[r + 1] - p4[l];
};
vector<ll> p5(n);
FOR(i,0,n)
p5[i+1] = min(ar[i]-1,d);
FOR(i,1,n+1)
p5[i] += p5[i-1];
auto getSum5 = [&](ll l, ll r) -> ll
{
return p5[r + 1] - p5[l];
};
ll ans = INF;
ll pos = 0;
ll cur;
FOR(i,0,n)
{
ll cc = 0;
ll cn = 0;
cc += getSum1(0,i-1);
pos = max(n-(i)*(k-1),i);
cc+= getSum5(pos,n-1);
cc+= getSum3(i+1,pos-1);
cn += getSum2(0,i-1);
cn+= getSum4(i,pos-1);
//cout << i << ' ' << pos << ' ' << cc << ' ' << cn<< endl;
if(-cn > cc)
continue;
cur = -cn*t;
cur+= i*pc;
cur+=(pos-i)*pm;
ans = min(ans,cur);
}
if(ans == INF)
ans = -1;
cout << ans;
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cerr << "____________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 2 18 1000 16 1 5 3 16 15
output:
1010
result:
ok single line: '1010'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
2 2 23 10 15 5 2 2 9 20
output:
-1
result:
ok single line: '-1'
Test #3:
score: -100
Runtime Error
input:
51 23 97 60 21 6 69 30 54 61 34 14 73 86 72 84 54 96 49 48 4 71 7 4 75 17 64 52 3 40 51 25 70 21 79 61 54 50 23 45 24 87 50 82 58 28 71 43 15 22 28 34 98 30 36 36 12 14 90