-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj15748.cpp
More file actions
44 lines (41 loc) · 876 Bytes
/
boj15748.cpp
File metadata and controls
44 lines (41 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
#include <queue>
using namespace std;
using p = pair<int, int>;
using ll = long long;
const int MAX = 10e+6;
const int INF = 0x66554433;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
priority_queue<p> pq;
int main(){
Quick_IO();
int L, N, F, B;
cin>>L>>N>>F>>B;
ll d = F - B;
for(int i = 0;i<N;i++){
int x, c;
cin>>x>>c;
pq.push({c, x});
}
int lastIndex = 0;
ll answer = 0;
while(!pq.empty()){
if(lastIndex<pq.top().second){
answer += (pq.top().second - lastIndex)*d*pq.top().first;
lastIndex = pq.top().second;
}
pq.pop();
}
cout<<answer<<"\n";
return 0;
}