이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
int n,m;
cin >> n >> m;
std::vector<int> times;
std::vector<int> positions;
for (int i = 0; i < m; i++) {
int tmp;
cin >> tmp;
times.push_back(tmp);
}
for (int i = 0; i < m; i++) {
int tmp;
cin >> tmp;
positions.push_back(tmp);
}
std::vector<int> idxes;
for (int i = 0; i < m; i++) {
idxes.push_back(i);
}
std::sort(idxes.begin(), idxes.end(), [times, positions](int ia, int ib){
int sa = times[ia] + positions[ia];
int sb = times[ib] + positions[ib];
return sa == sb ? times[ia] < times[ib] : sa < sb;
});
std::vector<int> frontier;
int num_arms = 0;
for (int idx : idxes) {
int selected_idx = -1;
int selected_score = 2100000000;
for (int i = 0; i < num_arms; i++) {
int idx2 = frontier[i];
if (positions[idx] == positions[idx2] && times[idx] == times[idx2]) continue;
if (positions[idx]-positions[idx2] > times[idx]-times[idx2]) continue;
if (selected_score < positions[idx2]) continue;
// cout << idx2 << " is better\n";
selected_score = positions[idx2];
selected_idx = i;
}
if (selected_idx == -1) {
// cout << "pushed" << "\n";
frontier.push_back(idx);
num_arms++;
} else {
// cout << "replaced " << selected_idx << "\n";
frontier[selected_idx] = idx;
}
// cout << "frontier: ";
// for (int i : frontier) {
// cout << i << " ";
// }
// cout << "\n";
}
cout << num_arms << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |