/ Randle /

记录详情

Accepted

/in/foo.cc: In function 'int read(int&)':
/in/foo.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 状态 耗时 内存占用
#1 Accepted 3ms 376.0 KiB
#2 Accepted 3ms 364.0 KiB
#3 Accepted 9ms 384.0 KiB
#4 Accepted 3ms 384.0 KiB
#5 Accepted 2ms 360.0 KiB
#6 Accepted 7ms 256.0 KiB
#7 Accepted 11ms 360.0 KiB
#8 Accepted 10ms 444.0 KiB
#9 Accepted 10ms 512.0 KiB
#10 Accepted 16ms 460.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++
递交时间
2017-08-06 20:35:45
评测时间
2017-08-06 20:39:22
评测机
分数
100
总耗时
79ms
峰值内存
512.0 KiB