当前位置:网站首页>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
边栏推荐
- Compte à rebours de 3 jours pour l'inscription à l'accélérateur de démarrage Google Sea, Guide de démarrage collecté à l'avance!
- 网络相关知识(硬件工程师)
- Redis Key-Value数据库 【秒杀】
- ESP8266与STC8H8K单片机联动——天气时钟
- Format check JS
- Google Play Academy 组队 PK 赛,正式开赛!
- cookie插件和localForage离线储存插件
- php按照指定字符,获取字符串中的部分值,并重组剩余字符串为新的数组
- Verifying downloaded files using sha256 files
- Spark概述
猜你喜欢
[C language] simple implementation of mine sweeping game
在uni-app中引入uView
Comment utiliser mitmproxy
Google play academy team PK competition, official start!
Oled12864 LCD screen
穀歌出海創業加速器報名倒計時 3 天,創業人闖關指南提前收藏!
Fundamentals of software testing
DRM display framework as I understand it
Unity shader learning notes (3) URP rendering pipeline shaded PBR shader template (ASE optimized version)
来自读者们的 I/O 观后感|有奖征集获奖名单
随机推荐
PHP inner class name is the same as the inner class method name
Summary of MySQL constraints
借力 Google Cloud 基础设施和着陆区,构建企业级云原生卓越运营能力
PHP read file (read JSON file, convert to array)
ROS2----LifecycleNode生命周期节点总结
神机百炼3.52-Prim
Deep learning classification network -- alexnet
Reading notes of cgnf: conditional graph neural fields
Vscode paste image plugin saves image path settings
Some descriptions of Mipi protocol of LCD
PHP development and testing WebService (soap) -win
php继承(extends)
外部中断无法进入,删代码再还原就好......记录这个想不到的bug
JS determines whether the mobile terminal or the PC terminal
深度学习分类网络--Network in Network
Flutter 混合开发: 开发一个简单的快速启动框架 | 开发者说·DTalk
Database learning summary 5
492.构造矩形
Replace Django database with MySQL (attributeerror: 'STR' object has no attribute 'decode')
No subject alternative DNS name matching updates. jenkins. IO found, the reason for the error and how to solve it