Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少. 思路: 以8人为例: x + y = 2,最小第一名,最大第一名:               1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1               x + y = 3,最小第一名,最大第二名.…
Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状,如: 1 2 3 2 1 → 1 2 3 2 1 1 2 3 1 2 → 1 2 3 1 1 8 10 6 → 8 10 6 10 6 8 → 10 6 6 问所有建筑的高度和最大为多少. 思路: 单调递增栈栈顶存储以当前点为峰的单侧最低高度下标,另存储以每个点为峰的左右最大高度和. #includ…
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最多上一次,所有客人菜单不能相同.给出三种菜的数量,问最多能接收多少客人. 思路: 一人一道 → 一人两道 → 一人三道. #include <bits/stdc++.h> using namespace std; int main() { int t;cin>>t; while(t--…
B. Different Rules Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rou…
题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n].C++代码: #include <iostream> using namespace std; ][]; int main() { cin >> n; ;i<=n;i++) f[i][] = f[][i] = ; ; i <= n; i ++) ;…
E. Pretty Song time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes m…
A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An n × n table a is defined as follows: The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for…
第二次写题解,请多多指教! http://codeforces.com/contest/1313/problem/C2 题目链接 不同于简单版本的暴力法,这个数据范围扩充到了五十万.所以考虑用单调栈的做法: 1.首先顺序逆序扫一遍,记录下每个点左边的最大高度和以及右边的最大高度和 存在l[i] r[i] 两个数组中: 2.第二步从前往后扫一边两个数组 ,得出每个点左右两边的最大高度和 l[i]+r[i]-a[i]; 以此找出最优的制高点,并标记其位置: 3.从制高点出发,向两边求高度.反向时,每…
Tired of boring office work, Denis decided to open a fast food restaurant. On the first day he made aa portions of dumplings, bb portions of cranberry juice and cc pancakes with condensed milk. The peculiarity of Denis's restaurant is the procedure o…
题:https://codeforces.com/contest/1313/problem/C2 题意:给出n个数,分别代表第i个位置所能搭建的最大高度,问以哪一个位置的塔的高度为基准向左的每一个塔都小于等于临近右边的塔,向右每一个塔都大于等于临近的左边的塔所构建的高度之和是最大的,输出最大的高度之和: 分析:我们设一个fir[i]数组,表示当前 i 位置向左能构造的最大高度和(就想阶梯一样,i位置是阶梯的最高处),sec[i]则是向右的: 因为求出这俩个数组后,我们直接o(n)的访问fir[i…