当前位置:网站首页>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_ About the geometric Mini batch

干货满满,这些知识你必须拿下
![[Title brushing] Super washing machine](/img/f9/0c69afafa8b32afc5df5e91d6af172.png)
[Title brushing] Super washing machine

Pytorch to onnx, onnxruntime reasoning in mmclas

【刷题篇】抽牌获胜的概率

Pre research of image scanning tool

VGA display color bar and picture (FPGA)

当字节跳动在美国输出中国式 996

"New continent" of mobile application going to sea

Innovation training (XI) summary of some bugs in the development process
随机推荐
Innovation training (x) advanced interface beautification
Record some settings for visual studio 2019
苹果电脑上MySQL安装完成找不到怎么办
Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
Application of short circuit expression (||) in C language
2064: [example 2.1] exchange value
Informatics Olympiad all in one 1000: introductory test questions
1005: estimation of the earth's population carrying capacity
2065: [example 2.2] sum of integers
leetcode 47. Permutations II 全排列 II(中等)
C#DBHelper_ FactoryDB_ GetConn
import torch_ Geometric first graph network example
Install MySQL database independently on Debian 10
import torch_geometric 的Data 查看
torch_ About the geometric Mini batch
成功跳槽阿里,进阶学习
D1 哪吒开发板 了解基本的启动加载流程
TCP的“非”可靠性
Implementing pytorch style deep learning framework similartorch with numpy
2067: [example 2.5] circle