UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214530#574. t3STASISZHY100738ms9508kbC++111.1kb2024-11-19 20:57:012024-11-19 23:02:28

answer

// Problem: A. t3
// Contest: undefined - NOIP2024训练赛 09
// URL: http://www.noi.ac/contest/1161/problem/574
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PII pair<int, int>

using namespace std;

const int N = 2e5 + 10, M = 1e6 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;

int n, m, q, ans, a, b, c;
int dp[N], val[3];
PII s[N];

vector<int> e[N];

priority_queue<int> pq[3];

signed main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> val[0] >> val[1] >> c; 
	for(int i = 1; i <= n; i ++) cin >> s[i].fi >> s[i].se;
	for(int i = 1; i <= n; i ++)
	{
		if(s[i].fi == s[i].se) continue;
		int now = s[i].se < s[i].fi;
		for(int j = 1; j <= abs(s[i].fi - s[i].se); j ++)
		{
			if(pq[now].empty() || i * c - pq[now].top() > val[now]) ans += val[now], pq[now ^ 1].push(i * c + val[now]);
			else ans += i * c - pq[now].top(), pq[now ^ 1].push(i * c * 2 - pq[now].top()), pq[now].pop();
		}
	}
	cout << ans << '\n';
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 0ms
memory: 9080kb

input:

50 4 401 83
1 9
0 10
1 1
7 5
6 2
6 10
5 10
5 5
4 4
10 8
8 3
4 8
8 0
1 2
8 9
9 9
4 6
8 7
3 10
2 4
9 3...

output:

12399

result:

ok "12399"

Test #2:

score: 0
Accepted
time: 0ms
memory: 9084kb

input:

50 1811 650 156
6 5
3 1
0 9
0 0
1 0
0 7
1 10
10 3
8 10
5 9
8 6
2 9
1 4
0 9
2 9
9 3
2 3
5 2
4 6
1 2
9...

output:

85235

result:

ok "85235"

Test #3:

score: 0
Accepted
time: 0ms
memory: 9076kb

input:

50 3618 899 582
1 2
5 3
10 7
3 6
6 9
5 4
7 10
4 0
1 4
1 9
8 9
10 10
6 9
0 5
6 9
9 8
0 10
1 8
6 2
0 1...

output:

253368

result:

ok "253368"

Test #4:

score: 0
Accepted
time: 3ms
memory: 9084kb

input:

50 425 1148 8
6 9
8 5
10 4
6 0
0 7
10 0
3 0
9 9
5 10
7 9
8 1
8 0
10 3
10 1
10 9
9 3
8 6
8 3
7 8
10 7...

output:

65368

result:

ok "65368"

Test #5:

score: 0
Accepted
time: 0ms
memory: 9080kb

input:

50 2232 2750 434
1 6
0 7
9 1
9 6
6 5
4 8
9 0
3 7
9 5
2 10
9 5
5 1
3 7
9 8
3 8
9 8
6 3
4 9
9 4
9 4
10...

output:

121406

result:

ok "121406"

Test #6:

score: 0
Accepted
time: 0ms
memory: 9080kb

input:

50 4039 2999 507
6 2
3 9
8 10
1 0
0 4
9 5
5 0
8 4
2 10
9 10
9 8
3 2
8 1
9 4
8 8
9 2
4 10
1 4
0 0
8 2...

output:

224049

result:

ok "224049"

Test #7:

score: 0
Accepted
time: 3ms
memory: 9084kb

input:

50 846 3248 933
1 10
5 10
8 7
4 6
6 2
3 2
0 0
2 2
6 5
4 0
9 0
0 3
1 5
8 0
1 8
9 7
1 6
8 10
1 7
7 10
...

output:

174023

result:

ok "174023"

Test #8:

score: 0
Accepted
time: 0ms
memory: 9084kb

input:

50 2653 3497 359
6 6
8 1
7 4
7 1
0 0
8 10
7 1
7 10
10 10
10 0
9 3
9 4
6 10
7 7
5 8
9 2
10 3
4 5
3 2
...

output:

330818

result:

ok "330818"

Test #9:

score: 0
Accepted
time: 0ms
memory: 9084kb

input:

50 4460 3746 785
1 3
0 3
6 2
10 6
6 9
2 7
2 1
1 8
3 5
6 0
9 6
6 4
10 4
7 3
9 7
9 7
8 10
0 0
5 9
6 4
...

output:

203160

result:

ok "203160"

Test #10:

score: 0
Accepted
time: 3ms
memory: 9084kb

input:

50 1267 3995 858
6 10
3 5
6 10
2 1
0 7
7 4
9 1
6 6
7 0
1 1
9 9
4 5
3 8
6 0
3 7
9 1
5 7
8 6
6 5
5 2
0...

output:

221209

result:

ok "221209"

Subtask #2:

score: 30
Accepted

Test #11:

score: 30
Accepted
time: 38ms
memory: 9272kb

input:

100000 100000000 100000000 1
4 1
7 1
7 6
7 5
7 5
6 6
5 1
1 4
2 0
3 0
5 7
1 9
1 1
6 8
2 5
7 7
7 9
6 3...

output:

211716275189

result:

ok "211716275189"

Test #12:

score: 0
Accepted
time: 34ms
memory: 9316kb

input:

100000 100000000 100000000 1
3 2
6 7
3 8
9 4
5 8
1 0
4 6
9 0
2 5
1 4
0 2
2 9
5 10
7 1
6 4
3 0
7 9
1 ...

output:

146913863207

result:

ok "146913863207"

Test #13:

score: 0
Accepted
time: 42ms
memory: 9248kb

input:

100000 100000000 100000000 1
2 2
5 1
0 0
0 4
2 0
7 6
2 0
6 6
2 10
10 8
5 9
2 9
8 7
8 5
0 4
10 4
6 9
...

output:

125015898506

result:

ok "125015898506"

Test #14:

score: 0
Accepted
time: 37ms
memory: 9508kb

input:

100000 100000000 100000000 1
1 3
5 7
7 3
2 3
10 3
1 0
0 5
3 2
3 4
7 1
0 4
3 9
0 5
9 10
4 3
6 9
6 9
0...

output:

306911415038

result:

ok "306911415038"

Test #15:

score: 0
Accepted
time: 34ms
memory: 9300kb

input:

100000 100000000 100000000 1
0 4
4 1
4 6
4 2
8 6
7 6
9 10
0 8
3 9
5 5
5 10
3 9
3 2
10 3
9 2
2 2
6 9
...

output:

83822988893

result:

ok "83822988893"

Test #16:

score: 0
Accepted
time: 33ms
memory: 9244kb

input:

100000 100000000 100000000 1
10 5
3 7
0 9
6 2
5 9
2 0
7 4
8 3
3 3
2 8
0 6
3 9
6 10
0 7
3 2
9 6
5 9
0...

output:

17837967511

result:

ok "17837967511"

Test #17:

score: 0
Accepted
time: 34ms
memory: 9248kb

input:

100000 100000000 100000000 1
9 6
2 1
8 0
8 1
2 2
7 6
5 9
5 10
4 8
0 1
6 1
4 9
9 8
1 1
7 1
5 10
5 9
5...

output:

146418351385

result:

ok "146418351385"

Test #18:

score: 0
Accepted
time: 39ms
memory: 9244kb

input:

100000 100000000 100000000 1
8 7
2 7
4 3
10 0
0 5
2 0
4 3
2 5
4 2
9 5
0 7
4 9
2 5
2 5
1 0
1 4
5 9
10...

output:

84017584381

result:

ok "84017584381"

Test #19:

score: 0
Accepted
time: 40ms
memory: 9292kb

input:

100000 100000000 100000000 1
7 8
1 1
0 6
1 0
8 8
7 6
2 8
10 1
4 7
6 9
6 3
5 10
5 3
3 9
5 0
8 8
5 8
4...

output:

18421668749

result:

ok "18421668749"

Test #20:

score: 0
Accepted
time: 36ms
memory: 9244kb

input:

100000 100000000 100000000 1
6 8
0 7
8 9
3 10
5 0
2 0
0 2
7 7
5 1
4 2
0 9
5 10
8 0
3 3
10 10
4 1
4 8...

output:

71718994500

result:

ok "71718994500"

Subtask #3:

score: 40
Accepted

Test #21:

score: 40
Accepted
time: 40ms
memory: 9248kb

input:

100000 30694440 93757838 144
1 4
0 5
9 3
3 8
6 9
7 4
3 5
6 1
6 6
4 5
10 0
9 4
7 4
9 1
5 4
8 4
2 0
10...

output:

11782941072

result:

ok "11782941072"

Test #22:

score: 0
Accepted
time: 33ms
memory: 9284kb

input:

100000 13169689 16407911 951
7 1
3 7
9 0
6 2
0 7
1 0
9 5
0 10
10 1
0 6
10 3
6 5
0 8
8 8
9 4
8 9
10 7...

output:

66599332884

result:

ok "66599332884"

Test #23:

score: 0
Accepted
time: 35ms
memory: 9248kb

input:

100000 95644938 91574337 758
2 8
6 9
8 8
9 8
6 5
6 8
5 6
5 8
3 6
6 6
10 6
4 6
5 2
8 4
3 4
8 4
8 3
3 ...

output:

82965110631

result:

ok "82965110631"

Test #24:

score: 0
Accepted
time: 34ms
memory: 9244kb

input:

100000 78120187 66740763 565
7 5
9 0
7 5
1 3
0 4
0 5
0 6
10 5
7 1
1 7
10 9
1 7
9 6
7 0
7 3
8 9
6 0
1...

output:

35524028010

result:

ok "35524028010"

Test #25:

score: 0
Accepted
time: 37ms
memory: 9436kb

input:

100000 60595436 41907189 372
2 1
1 2
6 3
4 8
6 2
5 2
7 6
4 3
0 6
8 7
10 2
10 8
2 0
6 7
0 3
8 3
3 7
6...

output:

77303496819

result:

ok "77303496819"

Test #26:

score: 0
Accepted
time: 38ms
memory: 9296kb

input:

100000 43070685 64557262 179
7 9
3 4
6 0
7 3
0 0
10 10
2 7
9 1
4 1
3 7
10 5
7 9
7 4
6 3
4 3
8 8
1 3
...

output:

57824985320

result:

ok "57824985320"

Test #27:

score: 0
Accepted
time: 34ms
memory: 9280kb

input:

100000 25545934 39723688 986
2 5
6 6
5 8
10 8
6 9
4 7
9 7
3 9
8 6
9 8
10 8
5 10
0 9
5 10
9 3
8 3
10 ...

output:

42292679046

result:

ok "42292679046"

Test #28:

score: 0
Accepted
time: 36ms
memory: 9376kb

input:

100000 60537536 14890114 793
7 2
9 7
4 6
2 3
0 7
8 4
4 7
8 7
1 1
4 8
10 0
2 0
4 3
4 6
2 2
8 8
7 7
6 ...

output:

45040697924

result:

ok "45040697924"

Test #29:

score: 0
Accepted
time: 38ms
memory: 9316kb

input:

100000 25488034 12706613 407
7 6
3 0
3 0
8 3
0 4
7 9
6 8
7 2
9 1
6 9
10 6
8 2
2 1
3 9
10 2
8 7
3 0
9...

output:

57925341606

result:

ok "57925341606"

Test #30:

score: 0
Accepted
time: 37ms
memory: 9320kb

input:

100000 7963283 87873039 214
2 2
6 2
2 9
0 9
5 2
1 6
2 8
1 0
1 7
1 9
10 10
6 2
6 5
2 5
4 2
8 2
0 7
6 ...

output:

83824996000

result:

ok "83824996000"