QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864419 | #1189. Wall Painting | cocoa_chan# | WA | 4ms | 8360kb | C++14 | 2.4kb | 2025-01-20 16:23:29 | 2025-01-20 16:23:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m,i,j,k,l,r,x,y,z,w,s,t,dp[1100000],len[1100000],neg,pos;
pair<pair<ll,ll>,ll> p[1100000];
multiset<ll> mxone[4],mxtwo[4],nointer;
set<pair<ll,pair<ll,ll>>> intersect[4];
pair<ll,pair<ll,ll>> pp;
void add(ll z,pair<ll,pair<ll,ll>> p)
{
//printf("(%lld:%lld,%lld,%lld)\n",z,p.first,p.second.first,p.second.second);
intersect[z].insert(p);
mxone[z].insert(dp[p.second.second]-p.first*pos);
mxtwo[z].insert(dp[p.second.second]-p.first*(neg+pos*2));
}
void del(ll z,pair<ll,pair<ll,ll>> p)
{
//printf("[%lld:%lld,%lld,%lld]\n",z,p.first,p.second.first,p.second.second);
intersect[z].erase(p);
mxone[z].erase(mxone[z].find(dp[p.second.second]-p.first*pos));
mxtwo[z].erase(mxtwo[z].find(dp[p.second.second]-p.first*(neg+pos*2)));
}
int main()
{
scanf("%lld %lld %lld %lld",&m,&n,&pos,&neg);
for(i=1;i<=n;i++)
{
scanf("%lld %lld %lld",&z,&x,&y);
p[i]={{x,y},z};
}
sort(p+1,p+n+1);
for(i=1;i<=n;i++)
{
//printf("(%lld)",i);
len[i]=p[i].first.second-p[i].first.first+1;
for(j=1;j<=3;j++)
{
while(!intersect[j].empty())
{
pp=(*intersect[j].begin());
if(pp.first<p[i].first.first)
{
del(j,pp);
nointer.insert(dp[pp.second.second]);
}
else
break;
}
}
//printf("?");
dp[i]=len[i]*pos;
if(!nointer.empty())
dp[i]=(*(--nointer.end()))+len[i]*pos;
//printf("?");
//printf("[%lld]",dp[i]);
for(j=1;j<=3;j++)
{
//printf("(%lld:%lld)",j,dp[i]);
if(p[i].second==j)
{
//printf("!");
if(!mxone[j].empty())
dp[i]=max(dp[i],(*(--mxone[j].end()))+p[i].first.first*pos+len[i]*pos-pos);
}
else
{
if(!mxtwo[j].empty())
dp[i]=max(dp[i],(*(--mxtwo[j].end()))+p[i].first.first*(neg+pos*2)+len[i]*pos-neg-pos*2);
}
}
//printf("!");
add(p[i].second,{p[i].first.second,{p[i].first.first,i}});
//printf("(%lld)\n",dp[i]);
}
s=0;
for(i=1;i<=n;i++)
{
s=max(s,dp[i]);
}
printf("%lld",s);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 8012kb
input:
8 5 10 5 1 1 7 3 1 2 1 5 6 3 1 4 3 6 8
output:
70
result:
ok answer is '70'
Test #2:
score: 0
Accepted
time: 0ms
memory: 7984kb
input:
26 3 9 7 1 11 13 3 1 11 3 18 26
output:
182
result:
ok answer is '182'
Test #3:
score: 0
Accepted
time: 0ms
memory: 8020kb
input:
21 10 10 5 1 10 21 3 4 16 1 1 7 3 11 21 3 1 16 3 3 3 2 1 17 3 5 18 1 7 11 2 3 14
output:
210
result:
ok answer is '210'
Test #4:
score: 0
Accepted
time: 0ms
memory: 8012kb
input:
21 15 8 7 2 12 21 2 1 2 3 6 13 2 13 17 1 11 19 3 3 5 1 12 13 3 2 2 1 12 15 1 5 17 1 2 3 1 1 9 1 8 12 3 8 9 3 2 9
output:
153
result:
ok answer is '153'
Test #5:
score: 0
Accepted
time: 0ms
memory: 8012kb
input:
8 5 36426 79445 3 6 8 3 1 2 3 1 4 1 1 7 1 5 6
output:
254982
result:
ok answer is '254982'
Test #6:
score: 0
Accepted
time: 0ms
memory: 8016kb
input:
5 8 29211 39679 1 5 5 1 3 4 2 3 4 3 3 5 1 1 5 1 1 5 3 2 5 3 1 5
output:
146055
result:
ok answer is '146055'
Test #7:
score: 0
Accepted
time: 1ms
memory: 8016kb
input:
14 4 95138 64223 2 11 12 2 2 11 2 8 13 3 8 14
output:
1141656
result:
ok answer is '1141656'
Test #8:
score: 0
Accepted
time: 0ms
memory: 8016kb
input:
19 9 70607 66466 3 8 9 2 5 10 2 16 18 2 4 18 3 1 4 3 9 10 2 10 15 2 4 14 3 1 3
output:
1270926
result:
ok answer is '1270926'
Test #9:
score: 0
Accepted
time: 1ms
memory: 8016kb
input:
11 8 45559 56553 3 2 5 2 3 8 2 3 9 1 1 7 1 5 11 2 3 8 1 7 11 1 1 4
output:
501149
result:
ok answer is '501149'
Test #10:
score: -100
Wrong Answer
time: 4ms
memory: 8360kb
input:
861607398 3876 81011 49233 3 394669701 515805550 3 88996129 148083649 3 522857002 746888599 2 645596889 805867588 3 30238644 820298182 3 8253822 719679027 1 121050605 803152099 1 511310692 691678587 3 41691669 810609226 3 125849609 390382629 2 91619093 835765994 3 113524757 737106256 1 579522464 794...
output:
69781110575365
result:
wrong answer expected '69780783122315', found '69781110575365'