# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61918 | 2018-07-27T05:14:46 Z | alex(#2140) | Zalmoxis (BOI18_zalmoxis) | C++11 | 1000 ms | 65492 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> #include <forward_list> using namespace std; struct node { int x; forward_list<int> l; }; forward_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_front({ x, forward_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_after(it->l.before_begin(), it2->l); a.erase_after(it); } else { c++; it->l.push_front(-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_front(-i); } for(auto it = r.begin(); it != r.end(); it++) { while(*it < 0 && c < k) { c++; (*it)++; r.insert_after(it, *it); } } for(auto it = r.begin(); it != r.end(); it++) printf("%d ", abs(*it)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 931 ms | 65144 KB | Output is correct |
2 | Correct | 895 ms | 65184 KB | Output is correct |
3 | Correct | 788 ms | 65184 KB | Output is correct |
4 | Correct | 795 ms | 65280 KB | Output is correct |
5 | Correct | 917 ms | 65280 KB | Output is correct |
6 | Correct | 923 ms | 65280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 843 ms | 65288 KB | Output is correct |
2 | Correct | 817 ms | 65308 KB | Output is correct |
3 | Correct | 810 ms | 65308 KB | Output is correct |
4 | Execution timed out | 1016 ms | 65312 KB | Time limit exceeded |
5 | Correct | 939 ms | 65492 KB | Output is correct |
6 | Execution timed out | 1085 ms | 65492 KB | Time limit exceeded |
7 | Correct | 912 ms | 65492 KB | Output is correct |
8 | Execution timed out | 1012 ms | 65492 KB | Time limit exceeded |
9 | Correct | 805 ms | 65492 KB | Output is correct |
10 | Correct | 476 ms | 65492 KB | Output is correct |
11 | Correct | 769 ms | 65492 KB | Output is correct |
12 | Correct | 160 ms | 65492 KB | Output is correct |
13 | Correct | 233 ms | 65492 KB | Output is correct |
14 | Correct | 177 ms | 65492 KB | Output is correct |