当前位置:网站首页>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
边栏推荐
- Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)
- Redis Key-Value数据库【初级】
- Ti millimeter wave radar learning (I)
- 官方零基础入门 Jetpack Compose 的中文课程来啦!
- JWT工具类
- Common websites for Postgraduates in data mining
- Redis Key-Value数据库 【秒杀】
- 外部中断无法进入,删代码再还原就好......记录这个想不到的bug
- Stc8h8k series assembly and C51 actual combat - digital display ADC, key serial port reply key number and ADC value
- PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
猜你喜欢
Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)
Google Go to sea entrepreneurship accelerator registration countdown 3 days, entrepreneurs pass through the guide in advance collection!
[C language] simple implementation of mine sweeping game
Keepalived installation, use and quick start
Can't the dist packaged by vite be opened directly in the browser
Summary of MySQL constraints
CNN可视化技术 -- CAM & Grad-CAM详解及pytorch简洁实现
keepalived安装使用与快速入门
The official zero foundation introduction jetpack compose Chinese course is coming!
Flutter 混合开发: 开发一个简单的快速启动框架 | 开发者说·DTalk
随机推荐
Lambda expressions and method references
token过期自动续费方案和实现
Leverage Google cloud infrastructure and landing area to build enterprise level cloud native excellent operation capability
No subject alternative DNS name matching updates. jenkins. IO found, the reason for the error and how to solve it
步骤详解 | 助您轻松提交 Google Play 数据安全表单
php读文件(读取json文件,转换为数组)
深度学习分类网络--VGGNet
51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)
How to use mitmproxy
谷歌出海创业加速器报名倒计时 3 天,创业人闯关指南提前收藏!
浏览器原理思维导图
Deep learning classification network -- vggnet
Shenji Bailian 3.52-prim
Verifying downloaded files using sha256 files
Shenji Bailian 3.54-dichotomy of dyeing judgment
mock-用mockjs模拟后台返回数据
Jetpack Compose 与 Material You 常见问题解答
[C language] simple implementation of mine sweeping game
Problems encountered in uni app development (continuous update)
ESP8266与STC8H8K单片机联动——天气时钟