Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)(VP-5,寒假加训)

VP时间

A.数学

设为ans

赢得为+,输的为-。

0=ans+sum;

1.ac

B.贪心

比较大小

找到最优解

min(p*n,b[i]*n);

结构体排序(从小到大)cmp(费用最小,可以转播最多人)

如果费用大于等于p就让本人通知费用更低

1.wa2

2.wa15

3.ac

C.数学

a[i]=a[i+1]modi;

如果a[i+1]是i的倍数那k==2

k-分界点

分界点就是余数发生变化

k最多为3

1.ac

D.

没思路

题解

A.

// Problem: A. Goals of Victory
// Contest: Codeforces - Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
// URL: https://codeforces.com/contest/1877/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 <ctime>
#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];
void solve() {
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n-1;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int ans=0-sum;
	cout<<ans<<'\n';
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

B.

// Problem: B. Helmets in Night Light
// Contest: Codeforces - Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
// URL: https://codeforces.com/contest/1877/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 <ctime>
#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;
struct node{
	int num,spend;
}a[N];
bool cmp(node a, node b){
	if(a.spend!=b.spend){
		return a.spend<b.spend;
	}else{
		return a.num>b.num;
	}
}
void solve() {
	ll n,p;
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i].num;
	}
	for(int i=1;i<=n;i++){
		cin>>a[i].spend;
	}
	sort(a+1,a+1+n,cmp);
	ll ans=0;
	ll sum=n;
	if(a[1].spend>=p){
		cout<<n*p<<'\n';
		return;
	}else{
		sum--;
		for(int i=1;i<=n;i++){
			if(a[i].spend>=p){
				ans+=sum*p;
				cout<<ans+p<<'\n';
				return;
			}else{
				if(sum>a[i].num){
					ans+=a[i].spend*a[i].num;
					sum-=a[i].num;
				}else{
					ans+=a[i].spend*sum;
					break;
				}
			}
		}
		ans+=p;
	}
	cout<<ans<<'\n';
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

C.//

// Problem: C. Joyboard
// Contest: Codeforces - Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
// URL: https://codeforces.com/contest/1877/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 <ctime>
#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;
void solve() {
	ll n,m,k;
	cin>>n>>m>>k;
	if(k>3){
		cout<<0<<'\n';
	}else{
		if(k==1){
			cout<<1<<'\n';
		}else if(k==2){
			if(m<=n){
				cout<<m<<'\n';
			}else{
				cout<<n+m/n-1<<'\n';
			}
		}else{
			if(m<=n){
				cout<<0<<'\n';
			}else{
				cout<<(m/n-1)*(n-1)+m%n<<'\n';
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值