# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61919 | 2018-07-27T05:15:49 Z | alex(#2140) | Zalmoxis (BOI18_zalmoxis) | C++11 | 892 ms | 96724 KB |
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; struct node { int x; list<int> l; }; list<node> a; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, k, i; scanf("%d%d", &n, &k); for(i = 0; i < n; i++) { int x; scanf("%d", &x); a.push_back({ x, list<int>(1, x) }); } int c = 0; for(i = 0; i < 30; i++) { for(auto it = a.begin(); it != a.end(); it++) { if(abs(it->x) != i) continue; auto it2 = next(it); if(it2 != a.end() && abs(it2->x) == i) { it->l.splice(it->l.end(), it2->l); a.erase(it2); } else { c++; it->l.push_back(-abs(it->x)); } if(it->x > 0) (it->x)++; else (it->x)--; } } auto &r = a.front().l; for(i = abs(a.front().x); i < 30; i++) { c++; r.push_back(-i); } for(auto it = r.begin(); it != r.end(); it++) { while(*it < 0 && c < k) { c++; (*it)++; r.insert(next(it), *it); } } for(auto it = r.begin(); it != r.end(); it++) printf("%d ", abs(*it)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 802 ms | 96376 KB | Output is correct |
2 | Correct | 751 ms | 96376 KB | Output is correct |
3 | Correct | 744 ms | 96448 KB | Output is correct |
4 | Correct | 761 ms | 96652 KB | Output is correct |
5 | Correct | 753 ms | 96652 KB | Output is correct |
6 | Correct | 752 ms | 96652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 751 ms | 96652 KB | Output is correct |
2 | Correct | 713 ms | 96652 KB | Output is correct |
3 | Correct | 756 ms | 96652 KB | Output is correct |
4 | Correct | 892 ms | 96652 KB | Output is correct |
5 | Correct | 818 ms | 96684 KB | Output is correct |
6 | Correct | 739 ms | 96684 KB | Output is correct |
7 | Correct | 827 ms | 96724 KB | Output is correct |
8 | Correct | 875 ms | 96724 KB | Output is correct |
9 | Correct | 881 ms | 96724 KB | Output is correct |
10 | Correct | 559 ms | 96724 KB | Output is correct |
11 | Correct | 674 ms | 96724 KB | Output is correct |
12 | Correct | 165 ms | 96724 KB | Output is correct |
13 | Correct | 171 ms | 96724 KB | Output is correct |
14 | Correct | 197 ms | 96724 KB | Output is correct |