| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 198096 | model_code | Santa Claus (RMI19_santa) | C++17 | 1079 ms | 2808 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* user: karagyozov-c76
* fname: Ivo
* lname: Karagyozov
* task: santa
* score: 30.0
* date: 2019-10-11 07:14:23.928835
*/
#include <bits/stdc++.h>
const int32_t MAX_N = 96068;
int32_t n, x[MAX_N + 5], h[MAX_N + 5], v[MAX_N + 5];
bool check(int32_t left, int32_t right) {
for(int32_t i = right + 1; i < n; i++) {
if(h[i] == 0) {
return false;
}
}
std::multiset< int32_t > s;
for(int32_t i = 0; i <= right; i++) {
if(h[i] == 0) {
s.insert(v[i]);
}
else {
if(i < left) {
auto it = s.lower_bound(v[i]);
if(it != s.end()) {
s.erase(it);
}
}
}
}
for(int32_t i = right; i >= left; i--) {
if(h[i] == 1) {
auto it = s.lower_bound(v[i]);
if(it != s.end()) {
s.erase(it);
}
}
}
return s.empty();
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int32_t t;
std::cin >> t;
for(int32_t cs = 1; cs <= t; cs++) {
std::cin >> n;
for(int32_t i = 0; i < n; i++) {
std::cin >> x[i];
}
for(int32_t i = 0; i < n; i++) {
std::cin >> h[i];
}
for(int32_t i = 0; i < n; i++) {
std::cin >> v[i];
}
int32_t last = -1;
for(int32_t i = 0; i < n; i++) {
while(last < i && check(last + 1, i)) {
last++;
}
if(last == -1) {
std::cout << -1 << " ";
}
else {
std::cout << 2 * x[i] - x[last] << " ";
}
}
std::cout << '\n';
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
