Submission #68439

# Submission time Handle Problem Language Result Execution time Memory
68439 2018-08-17T07:07:28 Z Bruteforceman Zalmoxis (BOI18_zalmoxis) C++11
15 / 100
1000 ms 92132 KB
#include <bits/stdc++.h>
using namespace std;
int a[1000010];
vector <int> v[1000010];
int alive[1000010];
 
int main(int argc, char const *argv[])
{
    int n, k;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        alive[i] = 1;
        v[i].emplace_back(a[i]);
    }
    int sz = n;
    while(sz < n + k) {
        int opt = -1;
        for(int i = 1; i <= n; i++) {
            if(alive[i] == 1) {
                if(opt == -1 || a[opt] >= a[i]) {
                    opt = i;
                }
            }
        }
        if(a[opt] == 30) break;
        int prev = -1;
        for(int i = opt - 1; i >= 1; i--) {
            if(alive[i] == 1) {
                prev = i;
                break;
            }
        }
        if(prev == -1 || a[prev] > a[opt]) {
            v[opt].emplace_back(a[opt]);
            ++a[opt];
            ++sz;
        } else {
            alive[prev] = 0;
            ++a[opt];
        }
    }
    for(int i = 1; i <= n; i++) {
        vector <int> tmp;
        while(v[i].size() > 1 && sz < n + k) {
            if(v[i].back() > 0) {
                int x = v[i].back();
                v[i].pop_back();
                v[i].emplace_back(x - 1);
                v[i].emplace_back(x - 1);
                ++sz;   
            } else {
                v[i].pop_back();
                tmp.emplace_back(0);
            }
        }
        for(auto j : tmp) {
            v[i].emplace_back(j);
        }
        for(auto j : v[i]) {
            printf("%d ", j);
        }
    }
    printf("\n");
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main(int, const char**)':
zalmoxis.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp:12:14: 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 Execution timed out 1086 ms 65028 KB Time limit exceeded
2 Execution timed out 1012 ms 67240 KB Time limit exceeded
3 Execution timed out 1086 ms 69376 KB Time limit exceeded
4 Execution timed out 1094 ms 71268 KB Time limit exceeded
5 Execution timed out 1093 ms 73392 KB Time limit exceeded
6 Execution timed out 1047 ms 75568 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 77588 KB Time limit exceeded
2 Execution timed out 1088 ms 79692 KB Time limit exceeded
3 Execution timed out 1092 ms 81704 KB Time limit exceeded
4 Execution timed out 1076 ms 83856 KB Time limit exceeded
5 Execution timed out 1082 ms 85972 KB Time limit exceeded
6 Execution timed out 1030 ms 88024 KB Time limit exceeded
7 Execution timed out 1085 ms 90040 KB Time limit exceeded
8 Execution timed out 1080 ms 92132 KB Time limit exceeded
9 Execution timed out 1063 ms 92132 KB Time limit exceeded
10 Execution timed out 1080 ms 92132 KB Time limit exceeded
11 Execution timed out 1075 ms 92132 KB Time limit exceeded
12 Correct 134 ms 92132 KB Output is correct
13 Correct 140 ms 92132 KB Output is correct
14 Correct 131 ms 92132 KB Output is correct