QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#725975 | #2375. Life Transfer | LaVuna47# | WA | 6ms | 5220kb | C++20 | 2.5kb | 2024-11-08 21:01:13 | 2024-11-08 21:01:15 |
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 __int128 INF = 1e17;
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+4);
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+4);
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+4);
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+4);
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
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 3620kb
input:
2 2 23 10 15 5 2 2 9 20
output:
-1
result:
ok single line: '-1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3492kb
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
output:
219
result:
ok single line: '219'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
62 76 65 65 8 10 7 72 94 1 11 41 83 91 4 70 19 28 47 64 30 32 32 92 72 9 67 39 29 26 83 65 79 45 4 90 18 79 47 70 47 1 45 29 61 35 76 36 100 52 21 1 25 73 44 17 50 6 73 22 58 69 97 72 5 47 45 2 16 54
output:
65
result:
ok single line: '65'
Test #5:
score: 0
Accepted
time: 6ms
memory: 5220kb
input:
43582 91310 55575 60047 23173 24006 84244 90822 47556 37222 9274 59666 85416 14744 35005 68454 92243 43165 77238 98571 35979 33713 55303 46369 99271 14106 83145 85719 24960 10970 27031 76453 72640 13498 74273 36393 7420 62304 20312 50811 16983 88563 2608 45583 60922 92615 97712 128 61820 40109 70023...
output:
60047
result:
ok single line: '60047'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
30 76 98 62 11 1 7 5 21 100 8 41 57 21 100 48 48 22 47 99 69 7 36 71 52 98 32 46 54 9 50 37 20 59 34 26 46 47
output:
62
result:
ok single line: '62'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
318 177 965 725 889 371 301 720 957 962 940 427 168 115 538 394 855 170 156 648 768 339 162 842 743 727 806 198 45 90 404 745 168 636 96 849 71 185 456 104 907 409 484 742 207 980 938 889 666 729 920 757 912 892 34 113 953 874 837 306 934 132 697 494 648 215 685 788 508 404 90 232 230 570 718 362 98...
output:
1450
result:
ok single line: '1450'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
5 5 98 93 75 5 23 23 86 78 93 29 75
output:
208
result:
ok single line: '208'
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3856kb
input:
564 83453 98047 82325 62361 34671 30179 68383 69883 54005 88534 68864 33147 24734 2808 4900 10246 56039 20228 98823 22204 68955 55645 27519 91231 89271 49115 81898 11717 10165 26024 17090 19388 94538 92624 23588 64646 28156 93838 25045 39929 84976 7138 55506 80692 93933 87161 79953 37973 28162 26580...
output:
-9180284430797838020
result:
wrong answer 1st lines differ - expected: '82325', found: '-9180284430797838020'