【无标题】

cpp 复制代码
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int f[101][25];
int main()
{
	int a[101]={0,534, 386, 319, 692, 169, 338, 521, 713, 640, 692, 969, 362, 311, 349, 308, 357, 515, 140, 591, 216,57, 252, 575, 630, 95, 274, 328, 614, 18, 605, 17, 980, 166, 112, 997, 37, 584, 64, 442, 495,821, 459, 453, 597, 187, 734, 827, 950, 679, 78, 769, 661, 452, 983, 356, 217, 394, 342, 697, 878,475, 250, 468, 33, 966, 742, 436, 343, 255, 944, 588, 734, 540, 508, 779, 881, 153, 928, 764, 703,459, 840, 949, 500, 648, 163, 547, 780, 749, 132, 546, 199, 701, 448, 265, 263, 87, 45, 828, 634};
	
	for(int i=1;i<=100;i++){
		int d=a[i]%24;
		f[i][d]=max(f[i][d],max(f[i-1][0]+a[i],f[i-1][d]));
		for(int x=1;x<24;x++){
			if(f[i-1][x])f[i][(x+d)%24]=max(f[i][(x+d)%24],max(f[i-1][x]+a[i],f[i-1][(x+d)%24]));
			else f[i][(x+d)%24]=f[i-1][(x+d)%24];
		}
	}
	cout<<f[100][0]<<endl;
	return 0;
}

来源:第十六届蓝桥杯模拟赛(第二期)c++答案与代码_小蓝准备请自己的朋友吃饭。小蓝朋友很多,最终吃饭的人总数达 2024 人(包括他自己-CSDN博客

相关推荐
小白菜又菜8 小时前
Leetcode 3432. Count Partitions with Even Sum Difference
算法·leetcode
wuhen_n9 小时前
LeetCode -- 15. 三数之和(中等)
前端·javascript·算法·leetcode
sin_hielo9 小时前
leetcode 2483
数据结构·算法·leetcode
Xの哲學10 小时前
Linux多级时间轮:高精度定时器的艺术与科学
linux·服务器·网络·算法·边缘计算
大头流矢10 小时前
归并排序与计数排序详解
数据结构·算法·排序算法
阿闽ooo10 小时前
外观模式:从家庭电源控制看“简化接口“的设计智慧
c++·设计模式·外观模式
油泼辣子多加10 小时前
【信创】算法开发适配
人工智能·深度学习·算法·机器学习
一路往蓝-Anbo10 小时前
【第20期】延时的艺术:HAL_Delay vs vTaskDelay
c语言·数据结构·stm32·单片机·嵌入式硬件
Aaron158811 小时前
AD9084和Versal RF系列具体应用案例对比分析
嵌入式硬件·算法·fpga开发·硬件架构·硬件工程·信号处理·基带工程
laocooon52385788611 小时前
插入法排序 python
开发语言·python·算法