Codeforces 301A Yaroslav and Sequence 【思维】
来源:互联网 发布:淘宝历史宝贝精灵 编辑:程序博客网 时间:2024/05/29 21:32
题目链接:Codeforces 301A Yaroslav and Sequence
题意:有
思路:其实对于
1、
2、
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#include <stack>#define PI acos(-1.0)#define CLR(a, b) memset(a, (b), sizeof(a))#define fi first#define se second#define ll o<<1#define rr o<<1|1using namespace std;typedef long long LL;typedef pair<int, int> pii;const int MAXN = 1e6 + 1;const int pN = 1e6;// <= 10^7const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;void add(LL &x, LL y) { x += y; x %= MOD; }int a[300];int main(){ int n; cin >> n; int cnt = 0; int ans = 0; int Min = INF; for(int i = 1; i <= 2*n-1; i++) { cin >> a[i]; cnt += a[i] < 0; ans += abs(a[i]); Min = min(Min, abs(a[i])); } while(cnt >= n) { cnt -= n; } if(n & 1) { cout << ans << endl; } else { if(cnt & 1) { cout << ans - 2*Min << endl; } else { cout << ans << endl; } } return 0;}
0 0
- Codeforces 301A Yaroslav and Sequence 【思维】
- codeforces 301 A Yaroslav and Sequence
- 【CF】CodeForces 301A Yaroslav and Sequence
- Yaroslav and Sequence - CodeForces 301A 水题
- codeforces 301a Yaroslav and Sequence
- A. Yaroslav and Sequence
- CodeForecs 301A Yaroslav and Sequence
- CodeForces 301A Yaroslav and Sequence(数字变号的最大和)
- Codeforces 301D Yaroslav and Divisors 【树状数组 + 思维】
- 【构造策略】-CF-301A-Yaroslav and sequence
- CodeForces 296A Yaroslav and Permutations
- codeforces301A. Yaroslav and Sequence
- codeforces 301D Yaroslav and Divisors
- codeforces 301B. Yaroslav and Time
- Yaroslav and Time - CodeForces 301B Dijkstra
- codeforces 301D Yaroslav and Divisors
- CodeForces 301B Yaroslav and Time
- 【CodeForces】222A - Shooshuns and Sequence(思维)
- 第2章 一切都是对象——Thinking-in-Java
- github学习之路(一)部署
- 内链接和外连接
- 15电气李书鹏 作业1
- 设计模式第八堂课
- Codeforces 301A Yaroslav and Sequence 【思维】
- git工作笔记
- [BZOJ1056][HAOI2008]排名系统(平衡树splay)
- MyBatis逆向工程
- Android开发 Activity的四种启动模式
- DB2存储过程入门
- 类的静态成员
- Qt之模型/视图(自定义按钮)
- 寻找Jar或者查询maven依赖写法的网址