# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
64785 |
2018-08-05T16:11:56 Z |
Good |
Zalmoxis (BOI18_zalmoxis) |
C++17 |
|
336 ms |
32520 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define Maxn 1000003
#define ll long long
#define pb push_back
#define Inf 1000000009
#define ppb() pop_back()
#define pii pair <int , int>
#define mid(x, y) (x + y) / 2
#define all(x) x.begin(),x.end()
#define llInf 1000000000000000009
#define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++)
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order;
int n, k;
ll cnt[33];
int A[Maxn];
deque <int> dq;
vector <int> E[Maxn];
int main () {
//freopen ("file.in", "r", stdin);
//freopen ("file.out", "w", stdout);
//srand ((unsigned) time ( NULL ));
//int randomNumber = rand() % 10 + 1;
scanf ("%d%d", &n, &k);
for (int i = 1; i <= n; i++)
scanf ("%d", A + i);
dq.push_front (30);
int p = 0;
int id = 1;
while(id <= n) {
int v = dq.front();
dq.pop_front();
if (v == A[id])
id ++;
else if (v < A[id])
E[id - 1].pb (v), p ++;
else {
v --;
if (v < 0) continue;
dq.push_front (v);
dq.push_front (v);
}
}
for (int i = 0; i < dq.size(); i ++)
E[id - 1].pb (dq[i]);
p += dq.size();
k -= p;
for (int i = 1; i <= n; i++) {
printf ("%d ", A[i]);
for (auto j: E[i]) {
memset (cnt, 0, sizeof (cnt));
cnt[j] = 1;
for (int l = j; l >= 1; l--) {
while (k > 0 and cnt[l] > 0)
cnt[l - 1] += 2, cnt[l] --, k --;
for (int h = 1; h <= cnt[l]; h++)
printf ("%d ", l);
}
}
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < dq.size(); i ++)
~~^~~~~~~~~~~
zalmoxis.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &n, &k);
~~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d", A + i);
~~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
228 ms |
29696 KB |
Output is correct |
2 |
Correct |
251 ms |
29960 KB |
Output is correct |
3 |
Correct |
229 ms |
29960 KB |
Output is correct |
4 |
Correct |
336 ms |
30044 KB |
Output is correct |
5 |
Correct |
262 ms |
30044 KB |
Output is correct |
6 |
Correct |
253 ms |
30044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
282 ms |
30044 KB |
Output is correct |
2 |
Incorrect |
301 ms |
30240 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
280 ms |
30240 KB |
Unexpected end of file - int32 expected |
4 |
Correct |
230 ms |
30252 KB |
Output is correct |
5 |
Correct |
310 ms |
30252 KB |
Output is correct |
6 |
Correct |
241 ms |
30252 KB |
Output is correct |
7 |
Correct |
316 ms |
30252 KB |
Output is correct |
8 |
Correct |
238 ms |
30252 KB |
Output is correct |
9 |
Incorrect |
223 ms |
32520 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
129 ms |
32520 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
250 ms |
32520 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
35 ms |
32520 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
32 ms |
32520 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
29 ms |
32520 KB |
Unexpected end of file - int32 expected |