Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using LL = long long int;
- template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
- template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
- while(*sdbg!=',')
- cerr<<*sdbg++;
- cerr<<"="<<h<<",";
- _dbg(sdbg+1, a...);
- }
- template<class T> ostream & operator<<(ostream & os, vector<T> V){
- os<<"[";
- for(auto vv: V) os << vv <<",";
- return os << "]";
- }
- template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
- return os <<"("<<P.st <<","<<P.nd <<")";
- }
- #ifdef DEBUG
- #define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
- #else
- #define debug(...) (__VA_ARGS__)
- #define cerr if(0)cout
- #endif
- int ans[100000];
- int main() {
- int n;
- cin >> n;
- vector<pair<int,int>> w0, m0, v;
- for (int i = 1; i <= n; ++i) {
- int x;
- cin >> x;
- v.push_back({x / 2, x % 2});
- }
- int sum = 0;
- for (auto x : v) {
- sum += x.first;
- }
- if (sum == 0) {
- for (auto x : v) {
- cout << x.first << endl;
- }
- return 0;
- }
- debug(sum);
- for (int i = 0; i < (int)v.size(); ++i) {
- if (v[i].second == 0) {
- continue;
- }
- if (sum < 0 && v[i].first >= 0) {
- v[i].first++;
- sum++;
- } else if (sum > 0 && v[i].first <= 0) {
- v[i].first--;
- sum--;
- }
- }
- int ss = 0;
- for (auto x : v) {
- ss += x.first;
- cout << x.first << endl;
- }
- assert(ss == 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement