제출 #1062801

#제출 시각아이디문제언어결과실행 시간메모리
1062801pravcoder전선 연결 (IOI17_wiring)C++17
0 / 100
1 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...