当前位置:网站首页>Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish
Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish
2022-07-02 06:06:00 【This question AC sleep again】


//
#include<bits/stdc++.h>
using namespace std;
const int N=33333;
const int V=66666;
int fish1[N],fish2[N];
int temp1,temp2,cnt1,cnt2,ans;
void init()
{
temp1=temp2=cnt1=cnt2=ans=0;
memset( fish1,0,sizeof( fish1 ) );
memset( fish2,0,sizeof( fish2 ) );
}
bool cmp( int a,int b )
{
return a>b ;
}
int main()
{
int n,v,x,y,i;
while( ~scanf("%d%d",&n,&v) )
{
init();
for( i=0;i<n;i++ )
{
scanf("%d%d",&x,&y);
if( x==1 ) fish1[cnt1++]=y;
else if( x==2 ) fish2[cnt2++]=y;
}
sort( fish1,fish1+cnt1,cmp ); // cnt1
sort( fish2,fish2+cnt2,cmp );
while( temp2<cnt2 ) // fish2 fill
{
if( 2*(temp2+1)<=v ) ans+=fish2[temp2++]; // <= Predetermination out of bounds
else break;
}
// temp2--; // here temp2 For quantity No reduction
while( temp1+2*temp2<v ) // fish1 fill Be careful not to take =
{
ans+=fish1[temp1++];
}
temp2--; // next while in temp2 Subscript subscript Need to get ( It can also be used below temp2-1 )
while( temp1<cnt1 )
{
if( fish2[temp2]<fish1[temp1]+fish1[temp1+1] ) // <=
{
ans+=( fish1[temp1]+fish1[temp1+1]-fish2[temp2] );
temp1+=2; temp2--;
}
else break; // Prevent falling into a dead cycle
}
printf("%d\n",ans);
}
return 0;
}//
find:
01 sort use cnt Sort
02 First use fish2 fill
1->2 false Last remaining 1 What do I do ?
2->1 true
03 fill fish1 Be careful not to take =
04 <= Predetermination out of bounds
05 temp Don't confuse the meaning
01 Number
02 Subscript
06 Deal with details
01 6e4*3e4==1.8e9 It's too big dp Overtime // k1 k2 Not initialized Compile error
02 1->2 more than 1 Not good treatment use 2—>1
03 The fish are not full even if they are all loaded What do I do ? cnt Count the remaining
边栏推荐
- PHP inner class name is the same as the inner class method name
- ES6的详细注解
- ZABBIX server trap command injection vulnerability (cve-2017-2824)
- Mock simulate the background return data with mockjs
- Some experience of exercise and fitness
- File contains vulnerability (I)
- Verifying downloaded files using sha256 files
- 在uni-app中引入uView
- External interrupts cannot be accessed. Just delete the code and restore it Record this unexpected bug
- 网络相关知识(硬件工程师)
猜你喜欢

Summary of MySQL constraints

memcached安装

CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现

Reading notes of cgnf: conditional graph neural fields

Deep learning classification network -- Network in network

我所理解的DRM显示框架

How to use mitmproxy

PHP development and testing WebService (soap) -win

500. Keyboard line

谷歌出海创业加速器报名倒计时 3 天,创业人闯关指南提前收藏!
随机推荐
神机百炼3.54-染色法判定二分图
Compte à rebours de 3 jours pour l'inscription à l'accélérateur de démarrage Google Sea, Guide de démarrage collecté à l'avance!
No subject alternative DNS name matching updates. jenkins. IO found, the reason for the error and how to solve it
PHP parent
Shenji Bailian 3.54-dichotomy of dyeing judgment
STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
Redis key value database [seckill]
ZABBIX server trap command injection vulnerability (cve-2017-2824)
Eco express micro engine system has supported one click deployment to cloud hosting
数据回放伴侣Rviz+plotjuggler
LCD之MIPI协议的一些说明
JWT工具类
Several keywords in C language
Reading notes of cgnf: conditional graph neural fields
File contains vulnerability (I)
借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
Frequently asked questions about jetpack compose and material you
495. Timo attack
How to use mitmproxy
Servlet web XML configuration details (3.0)