luogu2827 

和合并果子很像 合并果子是每次取最小的出来合并

 1 /*
 2 id:gww
 3 language:C--
 4   
 5 */
 6 #include<bits/stdc++.h>
 7 using namespace std;
 8 const int N=100000+10;
 9 int n,m,q,u,v,t,lj=0;
10 double p;
11 priority_queue<int> l;//优先队列 从大到小 
12 inline int rd()
13 {
14     int x=0,w=0;char ch=0;
15     while(!isdigit(ch)) w|=ch=='-',ch=getchar();
16     while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
17     return w?-x:x;
18 }
19  
20 int xqz(double x)
21 {
22     double a=x*p;
23     int ans=(int)a/1;
24     return ans;
25 }
26  
27 int main()
28 {
29     n=rd(),m=rd(),q=rd(),u=rd(),v=rd(),t=rd();p=(double)u/v;
30     for(int i=1;i<=n;i++) {int x=rd();l.push(x);}
31     for(int i=1;i<=m;i++)
32     {
33         int top=l.top()+lj,x1,x2;//被切的蚯蚓的长度
34         l.pop();lj+=q;//累加
35         x1=xqz((double)top),x2=top-x1;
36         l.push(x1-lj),l.push(x2-lj);
37         if(i%t==0) printf("%d ",top);
38     }
39     printf("\n");
40     for(int i=1;!l.empty();i++)
41     {
42         if(i%t==0) printf("%d ",l.top()+lj);
43         l.pop();
44     }
45     return 0;
46 }
65昏 优先对列

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2021-06-10
  • 2021-11-29
  • 2021-07-10
  • 2021-05-30
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2022-12-23
  • 2021-06-25
  • 2021-11-03
  • 2021-06-24
  • 2021-09-27
  • 2022-03-05
  • 2021-06-19
相关资源
相似解决方案