Submission #386991

#TimeUsernameProblemLanguageResultExecution timeMemory
386991rainboy자매 도시 (APIO20_swap)C++11
0 / 100
1 ms256 KiB
#include "swap.h"
#include <vector>

const int N = 100000, INF = 0x3f3f3f3f;

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int ww[N], n, m, ans, mn1, mn2, mn3;

void init(int n_, int m_, std::vector<int> ii, std::vector<int> jj, std::vector<int> ww_) {
	int h, ans;

	n = n_, m = m_;
	if (m == n - 1) {
		mn1 = mn2 = mn3 = INF;
		for (h = 0; h < m; h++) {
			ww[jj[h]] = ww_[h];
			if (mn1 > ww_[h])
				mn3 = mn2, mn2 = mn1, mn1 = ww_[h];
			else if (mn2 > ww_[h])
				mn3 = mn2, mn2 = ww_[h];
			else if (mn3 > ww_[h])
				mn3 = ww_[h];
		}
		ans = -1;
	} else {
		ans = 0;
		for (h = 0; h < m; h++)
			ans = max(ans, ww[h]);
	}
}

int getMinimumFuelCapacity(int i, int j) {
	return max(max(ww[i], ww[j]), mn3);
}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...