5 条题解
-
1
WiFi LV 8 @ 6 年前
-
18 年前@
http://blog.csdn.net/jackypigpig/article/details/70196695
洛谷上的评测需要卡卡常
本质上是个单调队列,但是要是用自带的queue会超时,通过一些推理可以将其转化为普通的队列。
具体可以看看我的博客 ^w^ -
08 年前@
-
08 年前@
单调队列233
考场码错了QAQ
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<ctime>
using namespace std;
int my_comp(int a,int b)
{
if(a>b) return 1;
return 0;
}
int d1[9*1000000],d2[9*1000000],d3[9*1000000];
int main()
{
int n,m,q,u,v,t,i,j,t1,l1,l2,l3;//freopen("earthworm.in","r",stdin);
//freopen("earthworm.ans","w",stdout);memset(d1,-128,sizeof(d1));
memset(d2,-128,sizeof(d2));
memset(d3,-128,sizeof(d3));scanf("%d%d%d%d%d%d",&n,&m,&q,&u,&v,&t);
l1=l2=l3=1;
for(i=1;i<=n;i++)
scanf("%d",&d1[i]);t1=t;
sort(d1+1,d1+n+1,my_comp);
for(i=1;i<=m;i++)
{
long long x1,x2,c,q1=d1[l1],q2=d2[l2],q3=d3[l3];
if(q1>=q2&&q1>=q3) {x1=d1[l1];l1++;}
else
{
if(q2>=q1&&q2>=q3) {x1=d2[l2];l2++;}
else {x1=d3[l3];l3++;}
}long long a=(x1+=(i-1)*q)*u/v;
d2[i]=a-i*q;
d3[i]=x1-a-i*q;if(i%t==0) printf("%d ",x1);
}printf("\n");
for(i=1;i<=n+m;i++)
{
int x1,x2,c,q1=d1[l1],q2=d2[l2],q3=d3[l3];
if(q1>=q2&&q1>=q3) {x1=d1[l1];l1++;}
else
{
if(q2>=q1&&q2>=q3) {x1=d2[l2];l2++;}
else {x1=d3[l3];l3++;}
}if(i%t==0) printf("%d ",x1+m*q);
}//fclose(stdin);
//fclose(stdout);return 0;
} -
-18 年前@
#include <bits/stdc++.h>
using namespace std;
priority_queue<int>q1;
queue<int>q2,q3;
int n,m,q,u,v,t;
int maxlen(int t){
int x1=-1,x2=-1,x3=-1;
if(!q1.empty())x1=q1.top()+t*q;
if(!q2.empty())x2=q2.front()+t*q;
if(!q3.empty())x3=q3.front()+t*q;
if(x1>=x2&&x1>=x3){q1.pop();return x1;}
else if(x2>=x1&&x2>=x3){q2.pop();return x2;}
else{q3.pop();return x3;}
}
int main(int argc,char** argv){
cin>>n>>m>>q>>u>>v>>t;
for(int i=1;i<=n;i++){int len;cin>>len;q1.push(len);}
for(int i=1;i<=m;i++){
long t1,t2,len=maxlen(i-1);
t1=len*u/v;t2=len-t1;
q2.push(t1-i*q);q3.push(t2-i*q);
if(i%t==0)cout<<len<<" ";
}cout<<endl;
for(int i=1;i<=m+n;i++){
int len=maxlen(m);
if(i%t==0)cout<<len<<" ";
}return 0;
}
- 1
信息
- ID
- 2007
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 1580
- 已通过
- 319
- 通过率
- 20%
- 被复制
- 8
- 上传者