【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

i从1..n/2循环一波。
保证a[i]和a[n-i+1]就好。
如果都是2的话填上min(a,b)*2就好
其他情况跟随非2的。

【代码】

#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std; const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0}; const int N = 20; int n,a,b,cost[2];
int c[N+10]; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
scanf("%d%d%d",&n,&a,&b);
cost[0] = a,cost[1] = b;
rep1(i,1,n) scanf("%d",&c[i]);
int ans = 0;
rep1(i,1,n/2){
int l = i,r = n-i+1;
if (c[l]==2 && c[r]==2){
ans+=min(a,b)*2;
}else{
if (c[l]==2){
ans+=cost[c[r]];
}else if (c[r]==2){
ans+=cost[c[l]];
}else if (c[l]!=c[r]){
cout<<-1<<endl;
return 0;
}
}
}
if (n&1){
if (c[n/2+1]==2){
ans+=min(a,b);
}
}
printf("%d\n",ans);
return 0;
}

【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) A】Palindrome Dance的更多相关文章

  1. 【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 翻转一次最多影响2k+1个地方. 如果n<=k+1 那么放在1的位置就ok.因为能覆盖1..k+1 如果n<=2k+1 ...

  2. Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) D mt19937

    https://codeforces.com/contest/1040/problem/D 用法 mt19937 g(种子); //种子:time(0) mt19937_64 g(); //long ...

  3. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  4. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D. Jury Meeting(双指针模拟)

    D. Jury Meeting time limit per test 1 second memory limit per test 512 megabytes input standard inpu ...

  5. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D

    Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the ...

  6. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) C

    Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n ...

  7. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B

    Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartme ...

  8. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A

    Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned tha ...

  9. 【Codeforces Round #430 (Div. 2) A C D三个题】

    ·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意:    给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...

随机推荐

  1. 【SpringMVC架构】SpringMVC入门实例,解析工作原理(二)

    上篇博文,我们简单的介绍了什么是SpringMVC.这篇博文.我们搭建一个简单SpringMVC的环境,使用非注解形式实现一个HelloWorld实例,从简单入手,逐步深入. 环境准备 我们须要有主要 ...

  2. Leetcode 贪心 Best Time to Buy and Sell Stock

    本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie Best Time to Buy and Sell Stock Total Accepted ...

  3. Cocos2d-X直接使用OpenGL接口

    Cocos2d-X是基于基于OpenGL ES的2D游戏引擎,所以Cocos2d-X能够直接使用OpenGL接口 首先建立一个Draw类,用于处理OpenGL接口 在Draw.h中加入以下的代码 #i ...

  4. 第17章 Redis概述

    17.2.1 在Windows下安装Redis https://github.com/ServiceStack/redis-windows/tree/master/downloads redis-se ...

  5. iOS开发中UIDatePicker控件的使用方法简介

    iOS上的选择时间日期的控件是这样的,左边是时间和日期混合,右边是单纯的日期模式. 您可以选择自己需要的模式,Time, Date,Date and Time  , Count Down Timer四 ...

  6. 用Webpack构建Vue项目

    开始之前,需要安装node环境.(安装过程在此就不啰嗦了)   1.创建基本结构 首先我们要创建一个空文件夹(我这里叫todos,你可以随便命名)作为项目的根目录. 创建一个没有任何依赖关系的pack ...

  7. RocketMQ之基本信息

    1.Producer 即消息生产者,负责产生消息,一般由业务系统负责产生消息. 2.Consumer 即消息消费者,负责消费消息,一般是后台系统负责异步消费. 3.Push Consumer Cons ...

  8. (转)vue router 如何使用params query传参,以及有什么区别

    写在前面: 传参是前端经常需要用的一个操作,很多场景都会需要用到上个页面的参数,本文将会详细介绍vue router 是如何进行传参的,以及一些小细节问题.有需要的朋友可以做一下参考,喜欢的可以点波赞 ...

  9. MSSQL数据库设置单用户模式后无法连上解决办法

    设置数据库单用户模式后, 发现用系统管理员账号无法连接数据库, 用sa账号也不行. 首先, 马上去查了一下有什么进程比这个连接给占用了 SELECT [Spid] = session_Id , eci ...

  10. 用来生成get set string 方法

    https://projectlombok.org/ 主要是用来生成get set string 方法等等 原理是注解