/ Randle /

记录详情

Time Exceeded

foo.cc: In function 'int read(int&)':
foo.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
正在同步测试数据,请稍后
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Time Exceeded ≥1099ms ≥384.0 KiB
#2 Time Exceeded ≥1099ms ≥384.0 KiB
#3 Time Exceeded ≥1097ms ≥384.0 KiB
#4 Time Exceeded ≥1004ms ≥384.0 KiB
#5 Time Exceeded ≥1100ms ≥384.0 KiB
#6 Time Exceeded ≥1101ms ≥384.0 KiB
#7 Time Exceeded ≥1100ms ≥384.0 KiB
#8 Time Exceeded ≥1100ms ≥384.0 KiB
#9 Time Exceeded ≥1101ms ≥384.0 KiB
#10 Time Exceeded ≥1102ms ≥384.0 KiB

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define N 25003
using namespace std;
inline int read(int &ret)
{
    ret=0;char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while('0'<=ch&&ch<='9')
    {
        ret=ret*10-'0'+ch;
        ch=getchar();
    }
}
int n,m,a[N],b[N];
int main()
{
    //freopen("spicychicken.in","r",stdin);
    //freopen("spicychicken.out","w",stdout);
    read(a[0]);read(b[0]);read(n);read(m);
    for(int i=n;i;--i)read(a[i]);
    sort(a,a+n+1,greater<int>());
    for(int i=0;i<=n;++i)a[i]=a[i]-a[i+1];
    sort(a,a+n+1);
    for(int i=m;i;--i)read(b[i]);
    sort(b,b+m+1,greater<int>());
    for(int i=0;i<=m;++i)b[i]=b[i]-b[i+1];
    sort(b,b+m+1);
    int p=1,q=1;
    ll ans=(ll)a[0]*m+(ll)b[0]*n;
    while(p<=n&&q<=m)
        if(a[p]<b[q])ans+=(ll)a[p++]*(m-q+1);
        else ans+=(ll)b[q++]*(n-p+1);
    printf("%lld\n",ans);
    return 0;
}

信息

递交者
类型
递交
题目
辣鸡
题目数据
下载
语言
C++
递交时间
2021-12-18 13:40:20
评测时间
2021-12-18 13:40:20
评测机
分数
0
总耗时
≥10907ms
峰值内存
≥384.0 KiB