CodeForces 610B Vika and Squares
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; const int maxn=+;
long long a[maxn],n;
long long Min;
long long ans;
long long b[maxn]; int main()
{
while(~scanf("%lld",&n)){
Min=;
for(long long i=;i<=n;i++) scanf("%lld",&a[i]);
for(long long i=;i<=n;i++) if(a[i]<Min) Min=a[i];
int tot=;
for(long long i=;i<=n;i++) if(a[i]==Min) b[tot++]=i;
ans=-;
for(int i=;i<tot;i++)
{
if(i<tot-)
{
long long ans2=(Min)*(n-b[i+]++b[i])+(Min+)*(b[i+]-b[i]-);
ans=max(ans,ans2);
}
else if(i==tot-)
{
long long ans2=(Min+)*(n-b[i]+b[]-)+Min*(b[i]-b[]+);
ans=max(ans,ans2);
}
}
printf("%lld\n",ans);
}
return ;
}
CodeForces 610B Vika and Squares的更多相关文章
- 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 ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 贪心
B. Vika and Squares 题目连接: http://www.codeforces.com/contest/610/problem/B Description Vika has n jar ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 水题
B. Vika and Squares Vika has n jars with paints of distinct colors. All the jars are numbered from ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares
B. Vika and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 599D Spongebob and Squares(数学)
D. Spongebob and Squares Spongebob is already tired trying to reason his weird actions and calculati ...
- codeforces 610B
Description Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n an ...
- codeforces 314E Sereja and Squares
discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). ...
- Codeforces 994 C - Two Squares
C - Two Squares 思路: 点积叉积应用 代码: #include<bits/stdc++.h> using namespace std; #define fi first # ...
- codeforces 425D Sereja and Squares n个点构成多少个正方形
输入n个点,问可以构成多少个正方形.n,xi,yi<=100,000. 刚看题的时候感觉好像以前见过╮(╯▽╰)╭最近越来越觉得以前见过的题偶尔就出现类似的,可是以前不努力啊,没做出来的没认真研 ...
随机推荐
- 【翻译】Longest Palindromic Substring 最长回文子串
原文地址: http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-i.html 转载请注明出处:http:// ...
- 使用onclick跳转到其他页面。使用button跳转到指定url
1. onclick="javascript:window.location.href='aa.htm'" 2. onclick="location='URL'&quo ...
- Codeforces Round #371 (Div. 2) C 大模拟
http://codeforces.com/contest/714/problem/C 题目大意:有t个询问,每个询问有三种操作 ①加入一个数值为a[i]的数字 ②消除一个数值为a[i]的数字 ③给一 ...
- 启动apache服务时报错【the requested operation has failed】
想要解决错误,首先要找到错误的原因. 使用ApacheMonitor.exe启动apache服务看不到任何错误的原因. 找到问题原因:cmd--命令端--切换到apache的bin目录,执行如下命令: ...
- Commit message 和 Change log 编写指南
来源:http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html Git 每次提交代码,都要写 Commit messa ...
- wl18xx编译的时候出现WARNING: "simple_open" WARNING: "wl12xx_get_platform_data"
................................................................................................... ...
- parted
1.选择分区表 sudo parted -s /dev/sdXX mklabel gpt 2.创建分区 sudo parted -s -- /dev/sdX mkpart primary 0 -1s ...
- Lua 基础 -- 学习笔记
标签(空格分隔): Lua 1. Lua可以一次性给多个变量赋值 变量比赋值多,多的变量就赋值nil 变量比赋值少,多的赋值舍弃 local a, b, c = 1, 2, 3 print( a, b ...
- POJ1556 The Doors 叉积+最短路
题目大意:求从(0,5)到(10,5)的最短距离,起点与终点之间有n堵墙,每个墙有2个门. 题目思路:判断两点间是否有墙(判断两点的连线是否与某一堵墙的线段相交),建立一个图,然后最短路求出就可以了. ...
- tab奇偶行颜色交替+插件
(function($){ $.fn.tableUI=function(options){ var defaults={ evenRowclass:"evenRow", oddro ...