codeforce 365 C. Compartments(gready,4级)

Chronos时间序列预测实战:从零开始微调你的第一个大语言模型(附完整代码) 本文提供了一份详细的Chronos时间序列预测大语言模型微调实战指南。从环境搭建、数据预处理到模型配置与训练,手把手教你如何利用自己的数据微调Chronos模型,并完成评估与部署,助你快速掌握这一前沿技术。 阅读详情

C. Compartments
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.

The students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.

However, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number.

After all the swaps each compartment should either have no student left, or have a company of three or four students.

Input

The first line contains integer n (1 ≤ n ≤ 106) — the number of compartments in the carriage. The second line contains n integersa1, a2, ..., an showing how many students ride in each compartment (0 ≤ ai ≤ 4). It is guaranteed that at least one student is riding in the train.

Output

If no sequence of swapping seats with other people leads to the desired result, print number "-1" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.

Sample test(s)
input
5
1 2 2 4 3
output
2
input
3
4 1 1
output
2
input
4
0 3 0 4
output
0


思路:贪心;见码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define clr(f,z) memset(f,z,sizeof(f))
using namespace std;
int f[6],ans;
void out()
{
  printf("%d 1:%d 2:%d 3:%d 4:%d\n",ans,f[1],f[2],f[3],f[4]);
}
int main()
{
  int n;
  while(~scanf("%d",&n))
  {
    int x;clr(f,0);
    FOR(i,1,n)
    {
      scanf("%d",&x);
      ++f[x];
    }
     ans=0;
      ///1->2;
    int zmin=min(f[2],f[1]);
    f[3]+=zmin;ans+=zmin;
    f[2]-=zmin;f[1]-=zmin;
    ///2 self
    f[3]+=2*(f[2]/3);ans+=2*(f[2]/3);
    f[2]%=3;
   // out();
   // out();
    ///1->1 to 3
    f[3]+=f[1]/3;ans+=2*(f[1]/3);
    f[1]%=3;

    if(f[1]<=f[3]){ans+=f[1];f[1]=0;}///1->3
    else f[2]+=f[1]/2,ans+=f[1]/2,f[1]%=2; ///1->1 2

    if(f[1])///left 1
    {
      if(f[1]<=f[3])ans+=f[1];///1->3
      else if(f[4]>=f[1]*2)ans+=f[1]*2;///4->1
      else ans=-1;///impossble
    }
    else if(f[2])
    {
      if(f[2]==2)ans+=2;///2->2 4
      else if(f[2]==1)
      {
        if(f[4])ans++;///4->2 3,3
        else if(f[3]>=2)ans+=2;///2->3 4
        else ans=-1;
      }
    }
    printf("%d\n",ans);
  }
}


对工时评估的思考:当AI颠覆了coding效率 在AI时代,“人日”作为软件工时度量衡已然失效。开发的价值核心正从“编码实现”转向“深度思考”与“精准沟通”——即如何将人类的模糊需求精确地传达给AI。当最有价值的“思想工作”变得最难量化时,传统的项目管理范式随之动摇。我们必须超越对过程的算计,开始探索衡量思想、沟通与业务价值的新标尺。 阅读详情

相关推荐

科研党必备!用Requests+BeautifulSoup升级版Nature爬虫(含PDF下载功能)

本文介绍了一套基于Python Requests和BeautifulSoup的Nature期刊智能爬虫系统,专为科研人员设计,可自动抓取论文标题、摘要及开放获取的PDF文档。系统采用模块化设计,包含请求管理、PDF检测和邮件通知等功能,确保高效合规地获取学术资源,提升科研效率。

weixin_29041767的博客 256

Contest Record

Contest 1135 at HZOI Problem A: 优美的棋发现一个可以证明的规律就是了……忘记给<<运算的左边变量转化为long long类型了,结果挂了20分……以后一定记得<<运算不会因为右边变量是long long类型而把运算改为long long类型啊……而且也要记得测试大数据来查错啊……Problem B: 优美的树50分的dp很好想……然后就...

weixin_30377461的博客 200

逆向分析美团外卖mtgsig3.0签名算法:从抓包到算法还原实战

在移动应用开发与安全领域,API接口签名是保障数据传输完整性与身份验证的核心机制。其基本原理是通过特定的算法,将请求参数、时间戳等数据与密钥结合,生成唯一的签名串,服务器通过验证签名来识别请求的合法性。这项技术的核心价值在于防止数据篡改、重放攻击和未授权访问,是构建安全客户端-服务器通信的基石。在实际应用中,签名算法广泛应用于电商、社交、金融等各类App的接口保护场景。本文以美团外卖App的mtgsig3.0签名为具体案例,详细拆解了其生成逻辑。通过结合Frida动态调试与Jadx静态分析,文章深入探讨了如

weixin_29325515的博客 1246

BFS:CF356C-Compartments

C. Compartments time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A team of students from the city S is sent to th

二营长的意大利炮友 494

Windows 24H2下eNSP AR_40启动失败的终极修复指南

本文针对Windows 11 24H2更新后eNSP AR_40路由器启动失败的问题,提供了终极修复方案。核心在于解决系统强制虚拟化安全(VBS/Hyper-V)与老版模拟软件的兼容性冲突。指南详细介绍了安装关键系统更新KB5053656、精细调整Windows虚拟化功能以及后续排错步骤,帮助用户在24H2系统上稳定运行eNSP进行网络实验。

weixin_29233333的博客 507

OpenMythos深度解析

本文深入解析了kyegomez/OpenMythos项目如何从第一性原理重建Claude Mythos的核心架构。该项目并非直接复制Claude,而是基于公开论文和实验结果推测其可能的设计理念,构建了包含多模态注意力、深度推理引擎、知识检索模块等六大核心组件的模块化架构。重点剖析了分组查询注意力(GQA)的实现细节,展示了KV头扩展等关键技术。该项目已成为大模型开源社区最受关注的研究之一,为理解Claude的架构思想提供了有价值的参考。

Crown_22的博客 518

Team Olympiad

Description The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others a

打得一手好铁 449

基于 STM32 设计的 HC05 蓝牙音箱

本项目介绍如何使用 STM32 微控制器和 HC05 蓝牙模块设计一个简单的蓝牙音箱。该音箱可以接收来自手机或其他蓝牙设备的音频数据,并通过扬声器播放。该项目展示了如何使用 STM32 微控制器和 HC05 蓝牙模块设计一个简单的蓝牙音箱。易于实现功能实用可扩展性强如果您需要开发一个蓝牙音箱,该项目可以作为参考。

走向CTO的路上... 2471

codeforces365A

#include #include//刚做codeforces上的比赛题我都没看懂啊啊啊啊啊啊 int main() { int n,m,i,k,visit[110],total; while(scanf("%d%d",&n,&m)!=EOF) { total=0; while(n--) { scanf("%d",&k); memset(visit,0,sizeof(visit))

晴朗的博客 891

【DRAM存储器七】SDRAM介绍-芯片引脚与功能框图详解

详解初代SDRAM芯片引脚定义与芯片功能框图中的各个模块

highman110的博客 2205

第39步 深度学习图像识别:Inception V3建模(Tensorflow)

第39步 深度学习图像识别:Inception V3建模(Tensorflow)

Jet4505的博客 3168

codeforces365B

#include int main() { int a,b,c,n,sum,max,i; while(scanf("%d",&n)!=EOF) { if(n scanf("%d",&a); printf("1\n"); continue; } scanf("%d%d",&a,&b); sum=2;max=2; for(i=3;i scanf("%d",&c); if(c=

晴朗的博客 826

解锁RK3588 HDMI输出:分辨率与EDID的深度探索

本文详细探讨了瑞芯微RK3588处理器的HDMI输出分辨率配置与EDID解析技术。文章首先介绍了RK3588处理器的性能特点及其HDMI功能在多媒体和工业领域的应用价值,随后分别阐述了HDMI输出分辨率的硬件连接要求和软件配置方法,包括4K/8K等不同分辨率的配置实例。在EDID部分,深入解析了EDID的数据结构、交互机制,以及数据获取与修改的具体方法。最后总结了配置过程中常见问题的解决方案,并展望了RK3588在高分辨率显示领域的发展前景。全文为开发者提供了RK3588 HDMI显示配置的完整技术指南。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 592

CodeForces490A. Team Olympiad 【贪心 队列】

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The School №0 of the capital of Berland has n children studying in it. All the children in ...

肖火柴的火柴盒 401

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

*C. Compartments----贪心

C. Compartments time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A team of students from the city S is sent t

bless295的博客 302

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

CodeForces - 417A(思维题)

Elimination Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u SubmitStatus Description The finalists of the "Russian Code Cup" competition i...

weixin_30908649的博客 218

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

codeforces-1198A MP3

codeforces-1198A 题意 给出一个大小为 n 的数组,和一个整数 I ; 大小为 n 的数组,如果数组中不同数值的个数为K,则需要 nk 位来装这些数, 你可以进行一个操作,选择一个数值区间 [ L ,R ] 把大于 R 的数变成 R ,小于 L 的数变成 L ;给出的整数 I 代表字节数,一个字节8个位;问如果要使这个的数组可以被 I 字节装下,至少有几个数会被改变。 思路 通过给...

weixin_43895356的博客 482

CodeForces - 25A IQ test (简单模拟)

Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the oth...

洛 水 422

codeforces 1217B-Zmei Gorynich(简单思维)

codeforces 1217B-Zmei Gorynich You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads! Initially Zmei Gorynich has x heads. You can...

qq_43148759的博客 483

Codeforces - 581A BowWow and the Timetable(思维 || !模拟)

In the city of Saint Petersburg, a day lasts for 2100 minutes. From the main station of Saint Petersburg, a train departs after 1 minute, 4 minutes, 16 minutes, and so on; in other words, the train de...

张洪基 694

codeforces 996B.World Cup(思维)

codeforces 996B. World Cup 题意: 开始Allen站在第一个门,如果当前门前面有人Allen会花费单位时间走到下一个门,如果没人Allen从这个门就进去了。球场的每个门,每单位时间可以进去一个人。问Allen最终是从哪个门进入球场的? 题解: 判断何时从这个门进,如果从第 i 个门进,第 i 个门有 k 个人,那么 x * n+ i > k ...

error311的博客 277

Codeforces - 1199C - MP3 - 尺取

https://codeforc.es/contest/1199/problem/C 擦,最后移位运算符溢出了,真的蠢。 肯定是选中间的连续的某段是最优的,维护这个段的长度和其中的元素种类就可以了。小心x可能很大导致溢出。 #include<bits/stdc++.h> using namespace std; typedef long long ll; inline in...

weixin_30882895的博客 148

Codeforces Round #576 (Div. 2) 题解

7.30号的cf,很久没打cf了,决定打一下,果然掉了10分。。。幸好还是蓝名。。。打完第二天就发了高烧也是无语。。。吃药在宿舍躺尸两天,决定把题解写下。。 A. City Day 题目很简单,不过英文有点绕。就是找到第一个符合的点,这个点是前面x个的值都比它大,后面y个的值都比它大。相当于一个凹点。当然,前面x可以不存在,后面y个也可以有不存在的。 代码如下: #include<bits/...

henuzxy 660

Codeforce 980 C. Posterized 思维

C. Posterizedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputProfessor Ibrahim has prepared the final homework for his algorithm’s class. He asked ...

qq_33859479的博客 268

CodeForces - 1199C CodeForces - 1198A mp3 (水题)

来源:CF-1199C C. MP3 One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can repre...

int_Brosea的博客 752

Codeforces 1198A MP3

传送门:MP3 MP3 One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represen...

Waiting For You 508
上一篇: codeforce 356 A. Knight Tournament(线段树覆盖,3级)
下一篇: UVALive 3887 Slim Span(枚举+MST,4级)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值