# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668176 | 2022-12-03T08:06:37 Z | MrDeboo | Zalmoxis (BOI18_zalmoxis) | C++17 | 150 ms | 19112 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long #define endl '\n' using namespace std; using namespace __gnu_pbds; using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,k; cin>>n>>k; deque<int>a,b(n); for(auto &i:b)cin>>i; deque<int>doq=b; deque<int>dq={b[0]}; a.push_back(b[0]); b.pop_front(); while(b.size()){ if(b[0]<=a.back()){ a.push_back(b[0]); dq.push_back(b[0]); b.pop_front(); }else{ k--; a.push_back(a.back()); dq.push_back(a.back()); } while(a.size()>1&&a.back()==a[a.size()-2]){ int A=a.back(); a.pop_back(); a.pop_back(); a.push_back(A+1); } } while(a.size()>1){ a.push_back(a.back()); dq.push_back(a.back()); k--; while(a.size()>1&&a.back()==a[a.size()-2]){ int A=a.back(); a.pop_back(); a.pop_back(); a.push_back(A+1); } } int g=a.back(); while(k--){ dq.push_back(g++); } int f=0; for(int i=0;i<dq.size();i++){ if(f<doq.size()&&doq[f]==dq[i])f++; } assert(f==doq.size()); for(auto &i:dq)cout<<i<<' '; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 18988 KB | Output is correct |
2 | Correct | 150 ms | 18980 KB | Output is correct |
3 | Correct | 136 ms | 18920 KB | Output is correct |
4 | Correct | 147 ms | 19032 KB | Output is correct |
5 | Correct | 135 ms | 19004 KB | Output is correct |
6 | Correct | 137 ms | 18964 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 136 ms | 19112 KB | not a zalsequence |
2 | Correct | 144 ms | 18984 KB | Output is correct |
3 | Incorrect | 136 ms | 18912 KB | not a zalsequence |
4 | Incorrect | 137 ms | 19104 KB | not a zalsequence |
5 | Incorrect | 135 ms | 19076 KB | not a zalsequence |
6 | Incorrect | 135 ms | 19012 KB | not a zalsequence |
7 | Incorrect | 143 ms | 18936 KB | not a zalsequence |
8 | Incorrect | 136 ms | 18944 KB | not a zalsequence |
9 | Incorrect | 124 ms | 17448 KB | not a zalsequence |
10 | Incorrect | 110 ms | 15736 KB | not a zalsequence |
11 | Incorrect | 106 ms | 16316 KB | not a zalsequence |
12 | Incorrect | 71 ms | 15388 KB | not a zalsequence |
13 | Incorrect | 72 ms | 15416 KB | not a zalsequence |
14 | Incorrect | 85 ms | 15360 KB | not a zalsequence |