/ Randle /

记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Wrong Answer 5ms 380.0 KiB
#2 Wrong Answer 9ms 280.0 KiB
#3 Wrong Answer 4ms 256.0 KiB
#4 Wrong Answer 19ms 384.0 KiB
#5 Wrong Answer 17ms 512.0 KiB
#6 Wrong Answer 18ms 392.0 KiB
#7 Wrong Answer 235ms 2.0 MiB
#8 Wrong Answer 260ms 2.0 MiB
#9 Time Exceeded ≥1006ms ≥876.0 KiB
#10 Time Exceeded ≥1003ms ≥880.0 KiB

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,k1,maxx=0,minn=0,l=0;
int a[400001],b[400001];
int ans;
int main()
{
 //freopen("kth.in","r",stdin);
 //freopen("kth.out","w",stdout);
 cin>>n>>k1;
 for(int i=1;i<=n;i++)
 cin>>a[i];
 for(int i=1;i<=n;i++)
  for(int j=i;j<=n;j++)
 {maxx=a[i];minn=a[i];
  for(int k=i;k<=j;k++)
  {maxx=max(maxx,a[k]);
   minn=min(minn,a[k]);
  }
  ans=maxx-minn;
  b[l]=ans;l++;
  //cout<<"{"<<ans<<" "<<i<<" "<<j<<"}"<<endl;
 }
 sort(b+1,b+l+1);
cout<<b[l-k1+1];
 return 0;
}

信息

递交者
类型
递交
题目
第k大区间 T2
题目数据
下载
语言
C++
递交时间
2018-08-22 21:05:16
评测时间
2018-08-22 21:05:16
评测机
分数
0
总耗时
≥2579ms
峰值内存
≥2.0 MiB