Codeforces Round 901 (Div. 2)(VP-10,寒假加训)

VP时间

A.模拟

先加时间少的

要在时间1的时候选择

B.博弈

我拿你的最大,你拿我的最大

结果看k的回合

k/2>n就还是n

k/2<n

就是最后几个小的变成G大的

看游戏回合

奇数

J多交换一次

偶数

一样次数

12345

56789

1<->9

1<->9

12345

1111111

拿最小的换

周期性

J拿a[min]-b[max]

G去还原

C.数学

没思路

D.dp

最优操作是删去最小的值

10000

先删去1,(11110)

先删去0,(22220)

这样mex才能变小

mex到mex-i 要删除mp[mex-i]个数

在转移过程中mex-i+1在做贡献次数是mp[mex-i-1](最后一次mex=mex-i)

mex>=0

所以dp[0]是最后一个转移到的点

状态转移方程

dp[j]=min(dp[j],dp[i]+i*(mp[j]-1)+j);

初始化dp[mex]=0

memset(dp,0x3f,sizeof(dp));

题解

A.

// Problem: A. Jellyfish and Undertale
// Contest: Codeforces - Codeforces Round 901 (Div. 2)
// URL: https://codeforces.com/contest/1875/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
struct node{
};
struct Lanthanmum{
	void start(){
		int m,b,n;
		cin>>m>>b>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		sort(a+1,a+1+n);
		ll ans=b;
		for(int i=1;i<=n;i++){
			ans+=min(m-1,a[i]);
		}
		cout<<ans<<'\n';
	}
}Genshin;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		Genshin.start();
	}
	return 0;
}

B.

// Problem: B. Jellyfish and Game
// Contest: Codeforces - Codeforces Round 901 (Div. 2)
// URL: https://codeforces.com/contest/1875/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N],b[N];
struct node{
};
struct Lanthanmum{
	void start(){
		int n,m,k;
		cin>>n>>m>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		for(int i=1;i<=m;i++){
			cin>>b[i];
		}
		sort(a+1,a+1+n);
		sort(b+1,b+1+m);
		ll ans=0;
		for(int i=1;i<=n;i++){
			ans+=a[i];
		}
		if(k&1){
			ans=max(ans,ans+b[m]-a[1]);
		}else{
			if(a[1]<b[m]){
				ans+=b[m]-a[1];
				swap(a[1],b[m]);
			}
			ans=min(ans,(ans+min(b[1],b[m])-max(a[1],a[n])));
		}
		cout<<ans<<'\n';
		
	}
}Genshin;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		Genshin.start();
	}
	return 0;
}

C.

应该先模拟的

一共有n个西瓜?,m个人

先分给m个人

n=n%m

然后在模拟

while(n)

ans+=n;//要把这些都切了再分

n*=2;切开了

n%=m;分给m个人

如果n可以被m整除就分完了

赛时可以定一个计时器超过100就不是

但原理应该是;

如果n不是2次幂就不可能分完

因为n/m会得到无限小数

lowbit(m)!=m就输出-1

因为西瓜?只能被分成两半,m如果存在3这种质因子,那就没办法分平均了

// Problem: C. Jellyfish and Green Apple
// Contest: Codeforces - Codeforces Round 901 (Div. 2)
// URL: https://codeforces.com/contest/1875/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lowbit(ll x){return x&(-x);}
struct node{};
struct Lanthanmum{
	void start(){
		int n,m;
		cin>>n>>m;
		int num=gcd(n,m);
		if(lowbit(m/num)!=m/num){
			cout<<-1<<'\n';
			return;
		}
		ll ans=0;
		n%=m;
		while(n){
			ans+=n;
			n*=2;
			n%=m;
		}
		cout<<ans<<'\n';
	}
}Genshin;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		Genshin.start();
	}
	return 0;
}

D.

// Problem: D. Jellyfish and Mex
// Contest: Codeforces - Codeforces Round 901 (Div. 2)
// URL: https://codeforces.com/contest/1875/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 5e4 + 9;
int dp[N];
struct node{
};
struct Lanthanmum{
	void start(){
		int n;
		cin>>n;
		map<int,int>mp;
		memset(dp,0x3f,sizeof(dp));
		for(int i=1;i<=n;i++){
			int x;
			cin>>x;
			mp[x]++;
		}
		int mex=0;
		while(mp[mex]){
			mex++;
		}
		dp[mex]=0;
		for(int i=mex;i>0;i--){
			for(int j=0;j<=i;j++){
				dp[j]=min(dp[j],dp[i]+i*(mp[j]-1)+j);
			}
		}
		cout<<dp[0]<<'\n';
	}
}Genshin;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		Genshin.start();
	}
	return 0;
}

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值