首先下午场非常适合中国人,开心

A

三种食物有个数限制,上菜,每次上菜跟以前的样式不能一样(食物的种类及个数各不相同),且每种食物最多用一次,问最多能上几次

对a,b,c排序,然后枚举上菜种类就可以了,注意最多能上7盘菜

    #include<bits/stdc++.h>
#define LL long long
#define maxn 100010
using namespace std; int d[][] = {{, , }, {, , }, {, , }, {, , }, {, , }, {, , }, {, , }}; int main(){
int T;
cin >> T;
while(T--){
int a, b, c;
cin >> a >> b >> c;
if(a < b){
swap(a, b);
}
if(a < c){
swap(a, c);
}
if(b < c){
swap(b, c);
}
int ans = ;
for(int i = ; i < ; ++i){
if(a >= d[i][] && b >= d[i][] && c >= d[i][]){
ans++;
a = a - d[i][];
b = b - d[i][];
c = c - d[i][];
}
}
cout << ans << endl;
}
return ;
}

B

就是有两场比赛,每场每个人都有一个独特的得分(从1到n),问给定分数最高排名跟最低排名(如果并列就按下算)

没有太多好说的,分析下可以知道第一个数是a+b-n+1,第二个数是a+b-1,注意让他们在1-n之间即可

#include<bits/stdc++.h>
#define LL long long
#define maxn 100010
using namespace std; int main(){
int T;
cin >> T;
while(T--){
int n, a, b;
cin >> n >> a >> b;
if(a + b < n){
cout << << " " << min(a + b - , n) << endl;
}
else{
cout << min(a + b - n + , n) << " " << min(a + b - , n) << endl;
}
}
return ;
}

C1 and C2

这个题的简单版本可以很轻松的暴力,这里主要说说C2的单调栈做法

首先这个a在建完之后一定有个峰值,在他的两边依次下降,那么我们怎么快速统计呢?可以用单调栈来做这个题

首先从1到n,如果栈不空且栈中元素大于当前元素,那么出栈一个数,否则结束,接下来我们统计如果这个点是峰值,左面的最大值

记录栈顶元素,如果栈空,则说明先前元素必须都得是当前元素,否则左边的最大值应该是从当前元素到栈顶元素全变为当前元素的总和加上栈顶元素做峰值的最大值

从1到n进行完一遍后,再从n到1进行一遍就易统计出右面的最大值

然后每个元素做峰值,序列总和最大值应该是左边+右面-当前元素的值,找到峰值之后,这个题便迎刃而解了

#include<bits/stdc++.h>
#define LL long long
#define maxn 500010
using namespace std; stack<int> st; LL use1[maxn], use2[maxn], a[maxn]; LL cl[maxn], rl[maxn]; signed main(){
int n;
cin >> n;
for(int i = ; i <= n; ++i){
cin >> a[i];
}
memset(use1, , sizeof use1);
memset(use2, , sizeof use2);
for(int i = ; i <= n; ++i){
if(st.empty() || a[st.top()] <= a[i]){
use1[i] = a[i] + use1[i - ];
st.push(i);
}
else{
while(!st.empty() && a[st.top()] > a[i]){
st.pop();
}
if(st.empty()){
use1[i] = a[i] * i;
}
else{
use1[i] = a[i] * (i - st.top()) + use1[st.top()];
}
st.push(i);
}
}
while(!st.empty()){
st.pop();
}
for(int i = n; i > ; --i){
if(st.empty() || a[st.top()] <= a[i]){
use2[i] = a[i] + use2[i + ];
st.push(i);
}
else{
while(!st.empty() && a[st.top()] > a[i]){
st.pop();
}
if(st.empty()){
use2[i] = a[i] * (n - i + );
}
else{
use2[i] = a[i] * (st.top() - i) + use2[st.top()];
}
st.push(i);
}
}
LL ans = ;
int id = -;
for(int i = ; i <= n; ++i){
//cout << use1[i] << " " << use2[i] << endl;
if(use1[i] + use2[i] - a[i] > ans){
ans = use1[i] + use2[i] - a[i];
id = i;
}
}
//cout << id << endl;
for(int i = id; i <= n; ++i){
if(a[i] < a[i + ]){
a[i + ] = a[i];
}
}
for(int i = id; i > ; --i){
if(a[i] < a[i - ]){
a[i - ] = a[i];
}
}
for(int i = ; i <= n; ++i){
cout << a[i] << " ";
}
cout << endl;
return ;
}

D跟E过的人不超过三位数,就不在考虑范围内了,这场难度偏难,虽然我也没想到打成这个b样子分还能涨一点

Codeforces Round #622 (Div. 2) 题解和我的分析的更多相关文章

  1. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  2. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  3. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  4. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  5. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  6. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  7. Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)(单调栈,递推)

    Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状, ...

  8. Codeforces Round #622 (Div. 2) B. Different Rules(数学)

    Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...

  9. Codeforces Round #622 (Div. 2) A. Fast Food Restaurant(全排列,DFS)

    Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最 ...

随机推荐

  1. Zenefits CodeSprint:Knight or Knave

    题意是一堆人,从1到n编号,每个人i说一句话,x.x是正数表示i说x君是个好人,x是负数表示i说x君是坏人.问这个群体中最多能有多少好人,把这种情况用字典序的方式输出(好人用A表示,坏人用B表示),希 ...

  2. AJAX请求返回JSON数据动态生成html

    1:DeliveryPersonVO对象 package com.funcanteen.business.entity.delivery.vo; import java.util.List; impo ...

  3. Linux 下安装 FFmpeg

    1. 下载源代码: git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg 2. 编译 ./configure --enable-shared --pre ...

  4. php实现简单链式操作mysql数据库类

    <?php $dbConfig = require_once(dirname(__FILE__).'/config.php'); class Db{     public $conn;      ...

  5. Hot Module Replacement [热模块替换]

    安装了webpack-dev-server后 , 配置 "start": "webpack-dev-server" 然后运行 npm start 会开起一个we ...

  6. 5.Nginx

    1.Nginx 安装 (1) 安装gcc (yum install gcc) 备注:可以输入gcc -v 查询版本信息,看系统是否自带安装 (2) 安装pcre (yum install pcre-d ...

  7. Java中Comparator的使用

    在某些特殊情况,我们需要对一个对象数组或集合依照对应的属性排序:此时,我们就可以用Comparator接口处理. 上代码 TestComparaTo 类 package com.test.interf ...

  8. AI算法工程师炼成之路

    AI算法工程师炼成之路 面试题: l  自我介绍/项目介绍 l  类别不均衡如何处理 l  数据标准化有哪些方法/正则化如何实现/onehot原理 l  为什么XGB比GBDT好 l  数据清洗的方法 ...

  9. JS之如何将Promise.then的值直接return出来

    不可能直接将Promise.then的值直接return出来,只能return出Promise对象,然后继续.then去操作异步请求得到的值.

  10. ZCGL大数据平台日常运维问题与解决方法

    问题:HBase停止 解决方法:重新启动HBase,如下所示 表层问题:插入和查询HBase速度比较慢 排查一,查看HBase节点状态,发现正常运行: 排查二,查看访问HBase服务的状态,发现服务停 ...