codeforces 610B
Description
Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.
Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2,3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.
Square is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.
The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.
Output
The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.
Sample Input
52 4 2 3 3
12
35 5 5
15
610 10 10 1 10 10
11 要涂油漆,有T(需要输入)种油漆,每种编号1,2,3,4....,没涂完一次,下一种油漆序号要比第一种大,如果到最大,那下一种就是1,输入各种油漆的数量,问你最多能涂多少油漆
#include <stdio.h>
#include <iostream>
using namespace std;
#define Maxn 210000
#define INF 1500000000
struct Node
{
long long int num;
}N[Maxn];
int main()
{
long long int T;
scanf("%lld",&T);
long long int min = INF;
long long int flag_big;
long long int flag_small;
long long int flag;
long long int bigger;
bool Q = false;
; i <= T; i++)
{
scanf("%lld",&N[i].num);
if (min > N[i].num)
{
min = N[i].num;
flag = i;
}
}
)
{
printf(].num);//我在这里错了十发- -
;
}
flag_small = flag;
; i <= T; i++)
{
if (min == N[i].num && flag < i)
{
flag = i;
Q = true;
}
}
flag_big = flag;
long long int biggest;
bigger = T - flag_big + flag_small -;
;
;
if (Q)
{
for(int i = flag_small; i <= T; i++)
{
if (N[i].num == min)
{
count = i - flag_small-;
flag_small = i;
}
if (count > cnt)
{
cnt = count;
}
}
biggest = max(cnt,bigger);
//long long Fuck;
//Fuck = T*min;
printf("%lld\n",T*min + biggest);
}
else
{
printf();
}
}
codeforces 610B的更多相关文章
- CodeForces 610B Vika and Squares
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...
- Codeforces Round #337 (Div. 2) 610B Vika and Squares(脑洞)
B. Vika and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- JSP技术
1. JSP技术简介 JSP全称是Java Server Pages,它和servlet技术一样,都是SUN公司定义的一种用于开发动态web资源的技术.是sun公司定义的一种规范,JSP实际上就是Se ...
- CentOS 6.5 IP 设置
DEVICE=eth0TYPE=EthernetUUID=7d6d54e0-054d-472b-8cc1-080f16ef36c1ONBOOT=yesNM_CONTROLLED=yesBOOTPROT ...
- zTree异步生成数据时无法获取到子节点的选中状态
最近在项目中遇到一个问题,需求如下: 根据选中不同的人员(ID)向后台发送ajax请求,通过返回的数据来生成该人员的权限访问树,该树目录最少为3级目录,在生成的时候会自动勾选上次保存过的选中状态,点击 ...
- Java字符串学习
Java中字符串是String类的实例,字符串也是对象,所以 Java将字符串作为对象进行管理 Java使用java.lang 包中的String类来创建字符串. 1.定义字符串: 使用 " ...
- windows 下PHP 和 nginx配置
http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html
- java单点登录系统CAS的简单使用
转:http://blog.csdn.net/yunye114105/article/details/7997041 背景 有几个相对独立的java的web应用系统, 各自有自己的登陆验证功能,用户在 ...
- MFC 如何改变对话框按钮上的文字
原文地址:http://blog.163.com/wenxianliang08@126/blog/static/8358326320110300643282/ 什么是标记菜单 如何标记菜单 如何 ...
- Selenium 自动化验收测试
Web 应用程序的验收测试常常涉及一些手工任务,例如打开一个浏览器,并执行一个测试用例中所描述的操作.但是手工执行的任务容易出现操作人员人为的错误,也比较费时间.因此,尽可能将这些任务自动化,以消除人 ...
- int 和String之间的互转
int -> String int i=12345;String s="";第一种方法:s=i+"";第二种方法:s=String.valueOf(i); ...
- 【木德木作杯楼市达人秀NO.28】南湖买房故事
应得意版主的邀请,我也来写写我的买房故事,虽然过程没有别人那么惊心动魄,但是毕竟是自己人生中非常重要的一件事情,就像恋爱一样,情话永远没有情书好,我也借此纪念一下这段短暂的时光.其中会涉及到本人对一些 ...