UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214528#574. t3erican100587ms3172kbC++112.3kb2024-11-19 20:41:192024-11-19 23:02:17

answer

/*  Erica N  */
#include <bits/stdc++.h>
using namespace std;
// #define pb push_back
#define mp make_pair
#define int long long
#define ull unsigned long long
#define pii pair<int, int>
#define ps second
#define pf first
#define itn int
#define rd read()
int read(){
    int xx = 0, ff = 1;char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')ff = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9')xx = xx * 10 + (ch - '0'), ch = getchar();
    return xx * ff;
}
// void write(int out) {
// 	if (out < 0)
// 		putchar('-'), out = -out;
// 	if (out > 9)
// 		write(out / 10);
// 	putchar(out % 10 + '0');
// }
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() { cerr << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cerr << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }


const int N = 3e5 + 5;
const int INF = 1e18;
const int M = 1e7;
const int MOD = 1e9 + 7;

// int f[N][N];//整理好前i个,且需要后面补充j个时的最小代价(j<0代表溢出到后面)
/*
反悔贪心

*/



priority_queue<int> pa,pb; // <id,tot>
int ans;
int a[N],b[N];

signed main() {
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);

    int n=rd,X=rd,Y=rd,Z=rd;
    for(int i=1;i<=n;i++){
        a[i]=rd;
        b[i]=rd;
    }
    // for(int i=1;i<=n;i++){
    //     b[i]=rd;
    // }


    for(int i=1;i<=n;i++){
        if(a[i]==b[i])continue;
        if(a[i]<b[i]){
            for(int j=1;j<=b[i]-a[i];j++){
                if(pb.size()&&i*Z-pb.top()<=X){
                    ans+=i*Z-pb.top();
                    pa.push(i*Z*2-pb.top());
                    pb.pop();
                }else{
                    ans+=X;
                    pa.push(i*Z+X);
                }
            }
        }else{
            for(int j=1;j<=a[i]-b[i];j++){
                if(pa.size()&&i*Z-pa.top()<=Y){
                    ans+=i*Z-pa.top();
                    pb.push(i*Z*2-pa.top());
                    pa.pop();
                }else{
                    ans+=Y;
                    pb.push(i*Z+Y);
                }
            }
        }


    }
    cout<<ans<<endl;
}

详细

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

Subtask #1:

score: 30
Accepted

Test #1:

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

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

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

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

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

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

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

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

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

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

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: 29ms
memory: 3024kb

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: 24ms
memory: 2964kb

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: 25ms
memory: 2912kb

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: 31ms
memory: 3172kb

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: 30ms
memory: 2988kb

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: 29ms
memory: 2960kb

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: 29ms
memory: 2992kb

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: 28ms
memory: 2916kb

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: 32ms
memory: 3024kb

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: 34ms
memory: 2960kb

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: 29ms
memory: 2952kb

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: 29ms
memory: 2972kb

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: 29ms
memory: 2916kb

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: 30ms
memory: 2972kb

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: 27ms
memory: 3124kb

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: 29ms
memory: 3008kb

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: 31ms
memory: 3028kb

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: 29ms
memory: 2992kb

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: 31ms
memory: 3020kb

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: 32ms
memory: 2908kb

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"