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

【题意】

在这里输入题意

【题解】

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. 系统报 “client没有所需的特权” 的解决方法

    今在对服务端代码进行单元測试的时候.突然报出例如以下错误: client没有所需的特权 后经网上查找,相同的问题都是属于对C盘读写的问题.回忆自己的项目也须要对C盘进行创建文件夹和读写文件.故尝试运行 ...

  2. [WPF]c#调用默认浏览器打开网址

    //调用系统默认的浏览器 System.Diagnostics.Process.Start("http://www.zhaokeli.com");

  3. 【cl】selenium实例2:打开百度,输入hello world

    /*创建的类为junit class*/ package Selenium_lassen; import static org.junit.Assert.*; import java.io.File; ...

  4. Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead的解决的方法

    今天在eclipse里报这个错误:   Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Plea ...

  5. JS——BOM操作(点击按钮返回顶部案例:scrollTop的用法)

    点击按钮返回顶部案例: 代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta chars ...

  6. Python编程Web框架 :Django 从入门到精通

    Django是一个高级别的Python Web框架,它鼓励快速开发和干净实用的设计. 现在我们开始学习它. Django学习之 第一章:Django介绍 Django学习之 第二章:Django快速上 ...

  7. 定义maven的项目结构

    创建一个Maven 的父项目 新建一个maven项目,选中create a simple project 填写以下内容: 如下内容: Group Id :edu.zipcloud.cloudstree ...

  8. MySQL 5.6 Reference Manual-14.5 InnoDB Tablespace Management

    14.5 InnoDB Tablespace Management   14.5.1 Resizing the InnoDB System Tablespace 14.5.2 Changing the ...

  9. 在YII2中使用memcached

    一.在本地安装Memcached服务器和安装memcached扩展 http://www.cnblogs.com/songziqing/p/5896742.html http://www.cnblog ...

  10. window环境下,提升工作效率

    效率工具 windows桌面程序 Listary 本地文件搜索器 有道词典 划词翻译, 并且能够存在生词本里面 印象笔记 浏览资料整理 chrom插件 crxMouse 鼠标手势 chrome vim ...