目录
Contest Info
[Practice Link](https://codeforces.com/contest/1237)
Solved | A | B | C1 | C2 | D | E | F | G | H |
---|---|---|---|---|---|---|---|---|---|
5/9 | O | O | O | O | O | - | - | - | - |
- O 在比赛中通过
- Ø 赛后通过
- ! 尝试了但是失败了
- - 没有尝试
Solutions
A. Balanced Rating Changes
题意:
给出(n)个数(a_i),保证(sum a_i = 0),现在需要将每个数变成(left lfloor frac{a_i}{2}
ight
floor)或者(leftlceil frac{a_i}{2}
ight
ceil),使得变化之后的所有数之和还是(0)
思路:
考虑全都变成(left lfloor frac{a_i}{2}
ight
floor),然后差了多少补上即可。
代码:
view code
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fi first
#define se second
#define endl "
"
using namespace std;
using db = double;
using ll = long long;
using ull = unsigned long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; }
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
#define dbg(x...) do { cout << "