QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725976#2375. Life TransferLaVuna47#WA 3ms6728kbC++202.5kb2024-11-08 21:01:572024-11-08 21:01:57

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 21:01:57]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6728kb
  • [2024-11-08 21:01:57]
  • 提交

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 = 1e15;

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: 1ms
memory: 3768kb

input:

2 2
18 1000 16 1
5 3
16 15

output:

1010

result:

ok single line: '1010'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3552kb

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: 3612kb

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: 3552kb

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: 5184kb

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: 3540kb

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: 3784kb

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: 3840kb

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: 0ms
memory: 3560kb

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: 1ms
memory: 3968kb

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: -100
Wrong Answer
time: 3ms
memory: 6728kb

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:

-9223191526311973927

result:

wrong answer 1st lines differ - expected: '178638', found: '-9223191526311973927'