답안 #145667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145667 2019-08-20T18:07:14 Z Blagojce Zalmoxis (BOI18_zalmoxis) C++11
0 / 100
479 ms 24484 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x),end(x)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
ll const inf = 1e9;
ll const mod = 998244853;
ld const eps = 1e-9;


int main()
{
        int n, k;
        cin >> n >> k;
        int a[n];
        int b[n];
        int MIN = 40;
        int nxt[n];
        fr(i, 0, n){
                cin >> a[i];
                b[i] = a[i];
                MIN = min(a[i], MIN);
                nxt[i] = i + 1;
        }
        nxt[n - 1] = n - 1;
        vector<pii> v;
        int sz = n;
        fr(mi, MIN, 30){
                int p = 0;
                fr(i, 0, sz - 1){
                        if(a[p] == mi){
                                if(a[nxt[p]] == mi){
                                        a[p] = mi + 1;
                                        nxt[p] = nxt[nxt[p]];
                                }
                                else{
                                        v.pb({i, mi});
                                        a[p] = mi + 1;
                                }
                        }
                        p = nxt[p];
                }
        }
        sort(v.begin(), v.end());
        int j = 0;
        k -= v.size();
        if(k > 0){
                cout << 2 / 0 << endl;
                return 0;
        }
        fr(i, 0, n){
                while(j < v.size() && v[j].st == i){

                        cout << v[j].nd <<' ';
                        j ++;
                }
                cout << b[i] <<' ';
        }
        cout <<endl;


        return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:55:27: warning: division by zero [-Wdiv-by-zero]
                 cout << 2 / 0 << endl;
                         ~~^~~
zalmoxis.cpp:59:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while(j < v.size() && v[j].st == i){
                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 392 ms 24164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Runtime error 393 ms 24380 KB Execution killed with signal 8 (could be triggered by violating memory limits)
3 Runtime error 393 ms 24184 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Runtime error 399 ms 24216 KB Execution killed with signal 8 (could be triggered by violating memory limits)
5 Runtime error 405 ms 24184 KB Execution killed with signal 8 (could be triggered by violating memory limits)
6 Runtime error 396 ms 24484 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 393 ms 24084 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Incorrect 479 ms 14112 KB not a zalsequence
3 Runtime error 394 ms 24400 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Runtime error 395 ms 24312 KB Execution killed with signal 8 (could be triggered by violating memory limits)
5 Runtime error 398 ms 24360 KB Execution killed with signal 8 (could be triggered by violating memory limits)
6 Runtime error 395 ms 24312 KB Execution killed with signal 8 (could be triggered by violating memory limits)
7 Runtime error 393 ms 24184 KB Execution killed with signal 8 (could be triggered by violating memory limits)
8 Runtime error 408 ms 24184 KB Execution killed with signal 8 (could be triggered by violating memory limits)
9 Runtime error 328 ms 21860 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Runtime error 134 ms 9956 KB Execution killed with signal 8 (could be triggered by violating memory limits)
11 Runtime error 213 ms 15116 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Runtime error 3 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
13 Runtime error 2 ms 376 KB Execution killed with signal 8 (could be triggered by violating memory limits)
14 Runtime error 3 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)