QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725970 | #2375. Life Transfer | LaVuna47# | WA | 10ms | 6900kb | C++20 | 2.4kb | 2024-11-08 20:59:22 | 2024-11-08 20:59:22 |
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+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
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
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: 3808kb
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: 3808kb
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: 1ms
memory: 3616kb
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: 3ms
memory: 5172kb
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: 3812kb
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: 1ms
memory: 3628kb
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: 3480kb
input:
5 5 98 93 75 5 23 23 86 78 93 29 75
output:
208
result:
ok single line: '208'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3580kb
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:
82325
result:
ok single line: '82325'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
6158 15278 43823 67615 4978 63699 88727 33282 77719 67731 33306 98068 14422 63259 45916 30211 13613 13914 7784 43496 19645 39454 93340 54306 78346 56423 90751 52171 7513 33252 7002 44852 96175 85892 85565 95015 12702 25692 25865 44354 74131 52784 16794 57577 58767 48332 26572 28227 98523 46865 97390...
output:
67615
result:
ok single line: '67615'
Test #11:
score: 0
Accepted
time: 10ms
memory: 6900kb
input:
74878 64717 88959 89319 37457 32099 8981 34750 86896 81749 94309 49998 80354 35423 61571 91269 67240 45199 37348 47368 57216 62409 19208 22998 8840 40045 1168 92838 77024 5819 15928 11261 35510 87736 31925 35590 38143 30966 26542 82888 89235 43716 35065 76523 99596 38380 49469 97128 66022 41482 7767...
output:
178638
result:
ok single line: '178638'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
5808 55534 43023 56965 605 27340 84039 3842 81602 71302 5402 2321 27176 93917 18412 88016 98194 46611 60816 12429 84566 58653 28140 3546 70006 9447 24227 37064 35897 41903 4184 34 43073 91739 3378 96773 88124 44894 11937 59101 27629 96194 58006 90339 83485 90409 82008 61450 94572 29201 19007 90101 9...
output:
56965
result:
ok single line: '56965'
Test #13:
score: 0
Accepted
time: 4ms
memory: 4632kb
input:
33246 52818 77 63 52 16 44774 68074 11 32 86 78 91 61 35 16 49 28 42 83 91 33 18 1 35 8 79 98 4 2 32 93 17 41 12 8 53 6 85 92 45 8 66 34 82 48 20 36 68 25 96 34 94 87 92 48 90 11 91 32 24 93 39 57 22 11 54 45 100 19 25 45 67 47 47 48 50 30 12 55 17 91 90 23 27 42 96 73 35 48 76 46 71 74 49 6 85 61 1...
output:
63
result:
ok single line: '63'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
8767 91010 98312 88704 81533 9267 72583 10494 90380 45362 16498 77529 96486 90049 63822 25130 90751 66840 14865 27674 89845 40253 93811 33109 18816 62628 94229 84807 86323 1842 17068 82167 2014 88732 20884 72963 27817 43538 27422 62702 17305 7536 37131 61696 87832 33217 7122 43724 35286 32613 39718 ...
output:
88704
result:
ok single line: '88704'
Test #15:
score: 0
Accepted
time: 5ms
memory: 4892kb
input:
36345 57977 88961 97289 71142 76195 16430 65187 69810 95203 79749 15646 42432 76061 32014 41590 72325 94712 65109 77200 39615 44281 66127 58712 45138 76005 84479 42292 70878 48161 94599 64491 74694 15873 37677 27779 27072 82986 60314 49542 16822 32135 84018 36162 88897 19652 6852 17399 47792 67559 5...
output:
97289
result:
ok single line: '97289'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 2 14 37 8 24 10 44 25 82
output:
37
result:
ok single line: '37'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
6 1 90 86 25 21 72 50 95 11 84 59 72 83
output:
1134
result:
ok single line: '1134'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
10 4 74 91 43 43 2 20 81 37 99 54 49 64 80 94 35 72
output:
268
result:
ok single line: '268'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
5 3 91 60 77 11 24 72 29 42 70 71 7
output:
1104
result:
ok single line: '1104'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
10 2 83 58 34 13 9 26 11 39 8 68 4 92 33 89 19 42
output:
505
result:
ok single line: '505'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 2 49 76 40 3 100 92 81 85 24 63 4 77 30 57 43 29
output:
310
result:
ok single line: '310'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
9 2 78 46 23 17 38 54 42 66 75 30 35 24 72 59 95
output:
153
result:
ok single line: '153'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
7 7 60 70 39 7 64 100 2 97 10 81 82 5 62
output:
70
result:
ok single line: '70'
Test #24:
score: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
9 2 87 19 11 10 0 59 61 13 77 5 78 10 43 5 71
output:
87
result:
wrong answer 1st lines differ - expected: '86', found: '87'