이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> v2i;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define rept(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
long long min_total_length(std::vector<int> r, std::vector<int> b) {
ll length = 0;
int n = r.size(), m = b.size();
int ptr1 = 0, ptr2 = 0;
int checked = 0;
vb checkedr(n, false), checkedb(m, false);
if (m > n) {
rep(i, m - n) {
checked += (2 - checkedr[0] - checkedb[ptr2]);
checkedr[0] = true;
checkedb[ptr2] = true;
length += b[ptr2++] - r[0];
}
}
rep(i, min(m, n)) {
checked += (2 - checkedb[ptr2] - checkedr[ptr1]);
checkedb[ptr2] = true;
checkedr[ptr1] = true;
length += b[ptr2++] - r[ptr1++];
}
if (n > m) {
rep(i, n - m) {
checked += (2 - checkedb[ptr1] - checkedr[n-1]);
checkedr[ptr1++] = true;
checkedb[n-1] = true;
length += b[ptr1++] - r[n - 1];
}
}
/*cout << "r";
for (auto c : checkedr) {
cout << " " << c;
}
cout << "\nb";
for (auto c : checkedb) {
cout << " " << c;
}*/
return length;
}
# | 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... |