齐工大联赛l题
#include <bits/stdc++.h>
#define lowbit(x) x&(-x)
#define ios std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0)
#define PII pair<int,int>
typedef long long ll;
using namespace std;
ll n,x,y,z,k,val,sum,a,b;
struct xxn
{
ll ks=0;
ll js=0;
}f[1000010];
bool jjw(xxn a,xxn b)
{
if(a.ks==b.ks) return a.js<b.js;
return a.ks<b.ks;
}
string s;
int main ()
{
cin>>n>>x>>y>>z>>k>>val;
b=x*y*z-1;
for(ll i=1;i<=n;i++)
{
cin>>s;
a=(s[0]-48)*10+s[1]-48;
f[i].ks+=a*y*z;
a=(s[3]-48)*10+s[4]-48;
f[i].ks+=a*z;
a=(s[6]-48)*10+s[7]-48;
f[i].ks+=a;
cin>>s;
a=(s[0]-48)*10+s[1]-48;
f[i].js+=a*y*z;
a=(s[3]-48)*10+s[4]-48;
f[i].js+=a*z;
a=(s[6]-48)*10+s[7]-48;
f[i].js+=a;
f[i].js+=k;
//cout<<f[i].ks<<" "<<f[i].js<<endl;
if(f[i].js>b) f[i].js=b;
}
sort(f+1,f+1+n,jjw);
//cout<<b<<' '<<f[n].js<<endl;
sum=(f[1].js-f[1].ks+1)*val;
//cout<<1<<' '<<sum<<endl;
for(ll i=2;i<=n;i++)
{
if(f[i].ks<=f[i-1].js&&f[i].js>f[i-1].js)
{
sum=sum+(f[i].js-f[i-1].js)*val;
//cout<<i<<" "<<1<<" "<<sum<<endl;
}
else if(f[i].ks>f[i-1].js)
{
//cout<<f[i].ks<<" "<<f[i-1].js<<endl;
sum=sum+(f[i].js-f[i].ks+1)*val;
//cout<<i<<" "<<2<<" "<<sum<<endl;
}
f[i].js=max(f[i-1].js,f[i].js);
}
cout<<sum<<endl;
return 0;
}
/*
3 4 4 4 1 1
00,00,00 00,00,01
00,00,01 00,00,02
00,00,02 00,00,03
5
2 44 44 44 1 1
00,00,01 00,00,04
00,00,02 00,00,03
5
2 23 12 62 5 1000000
06:03:60 06:04:21
06:04:26 06:05:19
178
4 44 44 44 1 2
00,00,01 00,00,04
00,00,06 00,00,07
00,00,05 00,00,08
00,00,02 00,00,03
18
4 44 44 44 1 1
00,00,04 00,00,11
00,00,06 00,00,24
00,00,05 00,00,08
00,00,02 00,00,03
2 44 44 44 1 1
00,00,01 00,00,11
00,02,00 01,11,22;
1 99 99 99 0 1000000
00,00,00 98,98,98
*/