# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68499 | 2018-08-17T08:26:55 Z | Bruteforceman | Zalmoxis (BOI18_zalmoxis) | C++11 | 1000 ms | 118172 KB |
#include <bits/stdc++.h> using namespace std; int a[1000010]; vector <int> v[1000010]; int alive[1000010]; struct data { int val, idx; data (int val, int idx) : val(val), idx(idx) {} data () {} bool operator < (data p) const { if(val == p.val) return idx < p.idx; return val > p.val; } }; 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; set <int> s; priority_queue <data> Q; for(int i = 1; i <= n; i++) { Q.emplace(a[i], i); s.insert(i); } while(sz < n + k) { while(alive[Q.top().idx] == 0) { Q.pop(); } int opt = Q.top().idx; Q.pop(); if(a[opt] == 30) break; int prev; auto it = s.lower_bound(opt); if(it == s.begin()) prev = -1; else prev = *(--it); if(prev == -1 || a[prev] > a[opt]) { v[opt].emplace_back(a[opt]); ++a[opt]; ++sz; Q.emplace(a[opt], opt); } else { alive[prev] = 0; s.erase(prev); ++a[opt]; Q.emplace(a[opt], opt); } } printf("%d\n", v[1].front()); exit(0); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1081 ms | 117860 KB | Time limit exceeded |
2 | Execution timed out | 1090 ms | 117860 KB | Time limit exceeded |
3 | Execution timed out | 1084 ms | 117904 KB | Time limit exceeded |
4 | Execution timed out | 1067 ms | 117932 KB | Time limit exceeded |
5 | Execution timed out | 1088 ms | 117932 KB | Time limit exceeded |
6 | Execution timed out | 1069 ms | 117932 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1077 ms | 118080 KB | Time limit exceeded |
2 | Execution timed out | 1078 ms | 118080 KB | Time limit exceeded |
3 | Execution timed out | 1074 ms | 118080 KB | Time limit exceeded |
4 | Execution timed out | 1084 ms | 118080 KB | Time limit exceeded |
5 | Execution timed out | 1080 ms | 118172 KB | Time limit exceeded |
6 | Execution timed out | 1087 ms | 118172 KB | Time limit exceeded |
7 | Execution timed out | 1086 ms | 118172 KB | Time limit exceeded |
8 | Execution timed out | 1081 ms | 118172 KB | Time limit exceeded |
9 | Execution timed out | 1080 ms | 118172 KB | Time limit exceeded |
10 | Incorrect | 730 ms | 118172 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 981 ms | 118172 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 24 ms | 118172 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 22 ms | 118172 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 21 ms | 118172 KB | Unexpected end of file - int32 expected |