当前位置:网站首页>Codeforces 1629 A. download more RAM - simple greed
Codeforces 1629 A. download more RAM - simple greed
2022-06-12 13:32:00 【Tianyi City*】
The question :
Tell you at first RAM The capacity of k. Now there is n Times operation , Each calculation needs to occupy you a[i] The capacity of RAM, And after the operation, it will not occupy , I will give it to you RAM increase b[i] Point capacity . But each can only be used once .
Ask you your RAM What is the last maximum .
Answer key :
So an obvious greed , We must be taking a The smallest first operation , Then bring it b.
#include<bits/stdc++.h>
using namespace std;
const int N=105;
struct node{
int a,b;
bool operator< (const node& aa)const {
return a<aa.a;
}
}a[N];
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n,k;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
scanf("%d",&a[i].a);
for(int i=1;i<=n;i++)
scanf("%d",&a[i].b);
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)
if(k>=a[i].a)
k+=a[i].b;
printf("%d\n",k);
}
return 0;
}
边栏推荐
- torch_ geometric message passing network
- 字节序数据读写
- 在 Debian 10 上独立安装MySQL数据库
- 软件构造 03 正则表达式
- It is enough to read this article. Web Chinese development
- 成功跳槽阿里,进阶学习
- 1414: [17noip popularization group] score
- Further understanding of the network
- Symbolic constant, const qualifier
- [wechat applet development] Part 1: development tool installation and program configuration
猜你喜欢
随机推荐
2068: [example 2.6] chicken and rabbit in the same cage
2063: [example 1.4] cattle eat grass
NVIDIA Jetson Nano Developer Kit 入门
创新实训(十)高级界面美化
Tensorrt, onnx to tensorrt in mmclas
Teach you how to create SSM project structure in idea
Tinyxml Usage Summary
Symbolic constant, const qualifier
事件的传递和响应以及使用实例
D1 哪吒开发板 了解基本的启动加载流程
成功跳槽阿里,进阶学习
403 you don't have permission to access this resource
成功定级腾讯T3-2,万字解析
【刷题篇】超级洗衣机
字节序数据读写
static 和 extern 关键字详解
The goods are full. You must take this knowledge
Seeking magic square of order n with C language
创新实训(十一)开发过程中的一些bug汇总
JVM 运行时参数









