URAL 1901 Space Elevators (苦逼水题,2级)

B - Space Elevators
Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Nowadays spaceships are never launched from the Earth's surface. There is a huge spaceport placed in the geostationary orbit and connected to the Earth with carbon nanotube cables. People and cargo are delivered to the orbit by elevators moving along these cables. It turned out that the space elevator is much more comfortable and cheaper than a spaceship.
Tomorrow a group of key employees of the “Akross” corporation will go to the spaceport with a secret mission. The spaceport management has reserved a special double elevator for the group. The Head of “Akross” demanded that at any given time the total importance of staff in the elevator must not exceed some fixed value. Under this condition, even in case of fatal accident the corporation will be able to recover. Employees enter the elevator in turns. The elevator is sent up if two people entered, or if only one person entered and the following person behind him is so significant for the corporation that it is impossible to send them together in one elevator.
The spaceport management wants to know the maximum number of elevator runs required to deliver all employees, so the right amount of oxygen cylinders and charged batteries can be prepared in advance.

Input

The first line contains integers n and s that are the amount of employees of “Akross” assigned to the mission, and the maximum total importance of two employees which can go together in the elevator (1 ≤ n ≤ 10 5; 1 ≤ s ≤ 10 9). The second line contains integers v 1, …, v n that are the importance of the employees (1 ≤ v is).

Output

In the first line output the maximum amount of trips of the elevator. In the second line output the importance of staff in order from the first employee in the line to the last, for which the elevator will do this amount of trips. If there are several possible answers, output any of them.

Sample Input

inputoutput
6 6
1 2 3 3 4 5
5
2 5 1 3 4 3

好吧:这就是昨晚死扣了两个多小时的题。算法很快就想到了,写程序速度也还行,可惜WA了,
         各种找错,最后也没找出来,然后向别人要了个正确的源程序对拍,终于对拍出了一个错误,2 e9+2居然会爆,哎我就无语了,改成long long 之后还WA,之后就各种对拍
        其实是对拍出问题浪费近一个小时,不知道为什么原先的对拍程序没结束,导致后来的运行都跑原先的程序,哎。。。。。
      找出问题后,手动删除,重新对拍,半天没拍出问题,然后,就没有然后了。。。。。。
              程序还是WA,不知道思路哪有问题,居然也没拍出来。。。。
  第一种思路:先选最小x,找到最小的y,使x+y>s 没有则选择次小,依次找完   无数的WA+苦逼的对拍,没找出问题,但还是WA
  第二种思路:先选最小x,找最大y,若x+y<=s则换次小值,依次找完   今天轻松1Y

#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
using namespace std;
const int mm=4e5+9;
const int oo=3e9+2;
map<int,int>mp;
map<int,int>::iterator it;
int f[mm],n,s,ans[mm],pos;
int main()
{
  while(~scanf("%d%d",&n,&s))
  { ans[0]=oo;
    mp.clear();
    mp[oo]=-1;
    mp[-oo]=-1;
    FOR(i,1,n)
    {
      scanf("%d",&f[i]);//mp[ f[i] ]++;
     // printf("tt=%d ",i);
    }
    sort(f+1,f+n+1);
    /*pos=1;int z;
    bool yes=0;
    while(1)
    { if(yes)
      z=s-ans[pos-1];
      else z=-1;
      it=mp.upper_bound(z);
     // printf("tt=%d %d\n",it->first,it->second);
      if(it->second<0)
      {
        it=mp.upper_bound(-1);
        if(it->second<0)break;
      }
      if(yes&&ans[pos-1]+it->second<=s)yes=0;
      else yes=1;
      ans[pos++]=it->first;
      if(it->second==1)mp.erase(it);
      else it->second--;
    }
    pos--;*/
    int l=1,r=n;pos=1;
    while(l<r)
    {
      if(f[l]+f[r]>s)ans[pos++]=f[l++],ans[pos++]=f[r--];
      else ans[pos++]=f[l++],ans[pos++]=f[l++];
    }
    //cout<<f[2]<<endl;
    if(l==r)ans[pos]=f[l];
    else pos--;
    int num=0;
    int zz=1;
    while(zz<=pos)
    { //printf("zz=%d %d\n",ans[zz],ans[zz-1]);
      LL zs=(LL)ans[zz]+(LL)ans[zz-1];
      if(zs>s)++zz,++num;
      else {++zz;//puts("++");
        if(zz>pos)break;++zz;++num;
      }
    }
    printf("%d\n",num);
    FOR(i,1,pos)
    printf("%d%c",ans[i],i==pos?'\n':' ');
  }
  return 0;
}


内容概要:本文提出了一种基于融合鱼鹰算法和柯西变异的改进麻雀优化算法(OCSSA),用于优化变分模态分解(VMD)的参数,进而结合卷积神经网络(CNN)与双向长短期记忆网络(BiLSTM)构建OCSSA-VMD-CNN-BILSTM模型,实现对轴承故障的高【轴承故障诊断】基于融合鱼鹰和柯西变异的麻雀优化算法OCSSA-VMD-CNN-BILSTM轴承诊断研究【西储大学数据】(Matlab代码实现)精度诊断。研究采用西储大学公开的轴承故障数据集进行实验验证,通过优化VMD的模态数和惩罚因子,有效提升了信号分解的准确性与稳定性,随后利用CNN提取故障特征,BiLSTM捕捉时间序列的深层依赖关系,最终实现故障类型的智能识别。该方法在提升故障诊断精度与鲁棒性方面表现出优越性能。; 适合人群:具备一定信号处理、机器学习基础,从事机械故障诊断、智能运维、工业大数据分析等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决传统VMD参数依赖人工经验选取的问,实现参数自适应优化;②提升复杂工况下滚动轴承早期故障的识别准确率;③为智能制造与预测性维护提供可靠的技术支持。; 阅读建议:建议读者结合Matlab代码实现过程,深入理解OCSSA优化机制、VMD信号分解流程以及CNN-BiLSTM网络架构的设计逻辑,重点关注参数优化与故障分类的联动关系,并可通过更换数据集进一步验证模型泛化能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值