Submission #151653

# Submission time Handle Problem Language Result Execution time Memory
151653 2019-09-04T03:43:25 Z baikdohyup Organizing the Best Squad (FXCUP4_squad) C++17
19 / 100
3000 ms 11000 KB
#include "squad.h"
#include <algorithm>
#include <iostream>

std::vector<int> arr1, arr2, arr3;
int N;

void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
	N = A.size();

	arr1 = A;
	arr2 = D;
	arr3 = P;
}

long long BestSquad(int X, int Y){
	long long firstA = 0, secondA = 0, firstD = 0, secondD = 0;
	int firstAidx = 0, firstDidx = 0;

	for (int i = 0; i < N; i++) {
		long long A, D;
		A = (long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y;
		D = (long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y;

		if (secondA <= A && A < firstA) {
			secondA = A;
		}
		if (secondD <= D && D < firstD) {
			secondD = D;
		}

		if (A >= firstA) {
			secondA = firstA;
			firstA = A;
			firstAidx = i;
		}
		if (D >= firstD) {
			secondD = firstD;
			firstD = D;
			firstDidx = i;
		}
	}

	if (firstAidx == firstDidx) {
		return firstA + secondD > firstD + secondA ? firstA + secondD : firstD + secondA;
	}
	else {
		return firstA + firstD;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 164 ms 10940 KB Output is correct
4 Correct 163 ms 10928 KB Output is correct
5 Correct 12 ms 1016 KB Output is correct
6 Correct 164 ms 10872 KB Output is correct
7 Correct 165 ms 11000 KB Output is correct
8 Correct 165 ms 10928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 25 ms 376 KB Output is correct
3 Execution timed out 3015 ms 11000 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 164 ms 10940 KB Output is correct
4 Correct 163 ms 10928 KB Output is correct
5 Correct 12 ms 1016 KB Output is correct
6 Correct 164 ms 10872 KB Output is correct
7 Correct 165 ms 11000 KB Output is correct
8 Correct 165 ms 10928 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 25 ms 376 KB Output is correct
11 Execution timed out 3015 ms 11000 KB Time limit exceeded
12 Halted 0 ms 0 KB -