QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375390 | #4088. 총 쏘기 | Unknown1508 | 0 | 0ms | 4060kb | C++20 | 1.3kb | 2024-04-03 10:05:01 | 2024-04-03 10:05:01 |
answer
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
int find_bad(const vector<int> &A, int limit = 1e9){
int res = -1, mx = -1;
for (int i = 0; i < min(limit, (int)A.size() - 1); i++){
if (A[i] <= mx) continue;
if (A[i] > A[i+1]){
res = i;
}
}
return res;
}
void remove(vector<int> &A, int idx){
vector<int> newA;
for (int i = 0; i < (int)A.size(); i++){
if (i != idx) newA.push_back(A[i]);
}
swap(A, newA);
}
vector<ii> min_shooting_buildings(vector<int> A){
if ((int)A.size() == 0) return {};
if ((int)A.size() == 1) return {{A[0], A[0]}};
int f1 = find_bad(A);
if (f1 < 0){
vector<ii> res = {{A[0], A[1]}};
remove(A, 0); remove(A, 0);
vector<ii> recur = min_shooting_buildings(A);
res.insert(res.end(), recur.begin(), recur.end());
return res;
}
int value = A[f1];
remove(A, f1);
int f2 = find_bad(A, f1);
if (f1 > 0 && f2 < 0) f2 = 0;
if (f2 < 0){
vector<ii> res = {{value, value}};
vector<ii> recur = min_shooting_buildings(A);
res.insert(res.end(), recur.begin(), recur.end());
return res;
}
vector<ii> res = {{value, A[f2]}};
remove(A, f2);
vector<ii> recur = min_shooting_buildings(A);
res.insert(res.end(), recur.begin(), recur.end());
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4028kb
input:
8 4 3 8 2 1 7 6 5
output:
4 6 7 2 8 3 4 1 5
result:
wrong answer Incorrect
Subtask #2:
score: 0
Wrong Answer
Test #26:
score: 12
Accepted
time: 0ms
memory: 3768kb
input:
8 5 6 7 1 2 8 3 4
output:
4 8 7 6 5 1 2 3 4
result:
ok Correct
Test #27:
score: -12
Wrong Answer
time: 0ms
memory: 3852kb
input:
16 2 4 5 1 9 10 3 6 14 7 8 11 12 16 13 15
output:
9 16 14 10 9 5 4 2 2 1 3 6 7 8 11 12 13 15 15
result:
wrong answer Incorrect
Subtask #3:
score: 0
Wrong Answer
Test #51:
score: 9
Accepted
time: 0ms
memory: 3728kb
input:
1 1
output:
1 1 1
result:
ok Correct
Test #52:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
2 1 2
output:
1 1 2
result:
ok Correct
Test #53:
score: 0
Accepted
time: 0ms
memory: 4024kb
input:
2 2 1
output:
2 2 2 1 1
result:
ok Correct
Test #54:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
3 1 3 2
output:
2 3 1 2 2
result:
ok Correct
Test #55:
score: 0
Accepted
time: 0ms
memory: 4052kb
input:
3 2 1 3
output:
2 2 2 1 3
result:
ok Correct
Test #56:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
3 2 3 1
output:
2 3 2 1 1
result:
ok Correct
Test #57:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
3 3 1 2
output:
2 3 3 1 2
result:
ok Correct
Test #58:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
4 2 1 4 3
output:
2 4 2 1 3
result:
ok Correct
Test #59:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
4 2 4 1 3
output:
2 4 2 1 3
result:
ok Correct
Test #60:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
4 3 1 4 2
output:
2 4 3 1 2
result:
ok Correct
Test #61:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
4 3 4 1 2
output:
2 4 3 1 2
result:
ok Correct
Test #62:
score: -9
Wrong Answer
time: 0ms
memory: 3788kb
input:
3 3 2 1
output:
2 2 3 1 1
result:
wrong answer Incorrect
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%