CSP-J Day 5 模拟赛补题报告

姓名:王胤皓,校区:和谐校区,考试时间: 2024 2024 2024 10 10 10 5 5 5 9 : 00 : 00 9:00:00 9:00:00~ 12 : 30 : 00 12:30:00 12:30:00,学号: S 07738 S07738 S07738

请关注作者的 B 站,谢谢~链接

CSP-J Day 5 5 5 模拟赛补题报告

前言

考了我们班 Rank 2 2 2

分数

T1 milk: A c c e p e t e d   100 \color{green}Accepeted\space100 Accepeted 100
T2 traary: A c c e p e t e d   100 \color{green}Accepeted\space100 Accepeted 100
T3 usagi: W r o n g _ A n s w e r   25 \color{red}Wrong\_Answer\space25 Wrong_Answer 25
T4 missiles: W r o n g _ A n s w e r   5 \color{red}Wrong\_Answer\space5 Wrong_Answer 5

T1

题面

在这里插入图片描述

思路

首先排序,然后贪心,累加一下,就行了。

赛时 A c c e p e t e d \color{green}{Accepeted} Accepeted 代码

#include<bits/stdc++.h>
using namespace std;
struct node{
   
   
	int num,money;
}a[200005];
bool cmp(node a,node b){
   
   
	if(a.money==b.money) return a.num>b.num;
	else return a.money<b.money;
}
int main(){
   
   
	freopen("milk.in","r",stdin);
	freopen("milk.out","w",stdout);
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1; i<=n; i++){
   
   
		cin>>a[i].num>>a[i].money;
	}
	sort(a+1,a+n+1,cmp);
	long long ans=0ll;
	for(int i=1; i<=n; i++){
   
   
		if(m>=a[i].num){
   
   
			m-=a[i]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Programming_Konjac

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值