2017ec final vp(ABCJKLM)

M-World Cup

面向样例模拟,判断 + 8 +8 +8 + 4 +4 +4 + 2 +2 +2 + 1 +1 +1 即可

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=1e5+10;
int a[10];

signed main(){
	int t=1;
	cin>>t;
	for(int temp=1;temp<=t;temp++){
		for(int i=1;i<=5;i++)
			cin>>a[i];
		int n;
		cin>>n;
		int ans=0;
		for(int i=1;i<=n;i++){
			int x;
			cin>>x;
			if(x<=48)
				ans+=a[1];
			else if(x<=56)
				ans+=a[2];
			else if(x<=60)
				ans+=a[3];
			else if(x<=62)
				ans+=a[4];
			else
				ans+=a[5];
		}
	cout<<"Case #"<<temp<<": ";
	cout<<ans<<"0000"<<endl;
	}
	return 0;
}

A-Chat Group

待补

C-Traffic Light

敢交就敢过。迫于精度要求放弃快读

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=1e5+10;
int a[10],b[N];

int T=1,t;
void solve(){
//	cout<<"Case #"<<t<<": ";
	int n;
	scanf("%lld",&n);
	int ans=0;
	double a,b,maxx=0;
	for(int i=1;i<=n+1;i++){
		int x;
		scanf("%lld",&x);
		ans+=x;
	}
	for(int i=1;i<=n;i++){
		scanf("%lf%lf",&a,&b);
		maxx=max(maxx,b);
	}
	printf("Case #%lld: ",t);
	printf("%.8lf\n",ans+maxx);
}

signed main(){
//	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	scanf("%lld",&T);
	for(t=1;t<=T;t++)
		solve();
	return 0;
}

K - Downgrade

每个等级需要对应的经验值才能够升入下一级,每次操作将当前的等级变为经验值,同时等级置 1 1 1,问 k k k 次操作后的等级及经验值。

读懂题意比实现痛苦,前缀和通过二分内置函数查找。

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=1e5+10;
int a[N],s[N],s1[N];

int T=1,t;
void solve(){
	int x,y,n;
	cin>>x>>y>>n;
	for(int i=1;i<=x;i++)
		cin>>a[i];
	for(int i=1;i<=x;i++)
		s[i]=s[i-1]+a[i];
	
	cout<<"Case #"<<t<<": ";
	if(x==1){
		cout<<"1-1"<<endl;
		return;
	}
	int nowa=x,nowb=y;
	for(int i=1;i<=n;i++){
		int pos=lower_bound(s+1,s+x+1,nowa)-(s+1);
		int la=pos+1;
		int lb=nowa-s[pos];
		if(nowa==la&&nowb==lb)
			break;
		nowa=la,nowb=lb;
	}
	cout<<nowa<<"-"<<nowb<<endl;
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//	scanf("%lld",&T);
	cin>>T;
	for(t=1;t<=T;t++)
		solve();
	return 0;
}

L - SOS

S_ _S 为必胜态,此时后手不能在该结构内做任何操作,考虑如何构造该结构。

没想通怎么过的,加了个 i f if if 判断从 n ≥ 10 n≥10 n10 摁草到 n ≥ 16 n≥16 n16

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=1e5+10;
int a[N],s[N],s1[N];

int T=1,t;
void solve(){
	int n;
	cin>>n;
	cout<<"Case #"<<t<<": ";
	if(n<=6)
		cout<<"Draw"<<endl;
	else if(n%2==1)
		cout<<"Panda"<<endl;
	else if(n>=16)
		cout<<"Sheep"<<endl;
	else
		cout<<"Draw"<<endl;

}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//	scanf("%lld",&T);
	cin>>T;
	for(t=1;t<=T;t++)
		solve();
	return 0;
}

B - Scapegoat

分配 m m m 个人解决 n n n 个问题,问题具有严重性,多人解决同一问题时将平分该问题的严重性。求每个人实际承担的严重性与平均承担严重性的最小方差。

优先队列,首先所有问题都分配一个人,按向该问题多增加一个人解决后对方差的减少值作为排序,有公式

( 问 题 严 重 性 解 决 人 数 − 平 均 值 ) 2 ∗ 解 决 人 数 − ( 问 题 严 重 性 解 决 人 数 + 1 − 平 均 值 ) 2 ∗ ( 解 决 人 数 + 1 ) (\frac{问题严重性}{解决人数}-平均值)^2*解决人数-(\frac{问题严重性}{解决人数+1}-平均值)^2*(解决人数+1) 2+12+1

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=2e5+10;
int a[N],s[N],s1[N];

struct Node{
	double v;
	int num;
	int people;
	bool operator<(const Node&t)const{
		return t.v>v;
	}
};

int T=1,t;
void solve(){
	priority_queue<Node> q;	
	int n,m;
	cin>>n>>m;
	double sum=0;
	double ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}	
	sum/=m;
	for(int i=1;i<=n;i++){
		q.push({pow(a[i]-sum,2)-pow(a[i]/2.0-sum,2)*2,i,1});
		ans+=(a[i]-sum)*(a[i]-sum);
	}
	for(int i=1;i<=m-n;i++){
		auto now=q.top();
		q.pop();
		ans-=now.v;
//		cout<<now.num<<" "<<now.v;
		now.people++;
		double value=pow((a[now.num]*1.0/now.people-sum),2)*(now.people)-pow((a[now.num]*1.0/(now.people+1)-sum),2)*(now.people+1);
		q.push({value,now.num,now.people});
	}
	
	printf("Case #%lld: ",t);
	printf("%.10lf\n",ans/m);
}

signed main(){
//	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//	scanf("%lld",&T);
	cin>>T;
	for(t=1;t<=T;t++)
		solve();
	return 0;
}

J - Straight Master

待补

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值