Submission #2382338


Source Code Expand

#include <iostream>
#include <algorithm>

void calc(int A, int B)
{
	if (A > B) {
		std::swap(A, B);
	}

	long long A_B = (long long)A * B;
	long long A1 = A + 1;
	int i = B - 1, count = 0;
	while (i >= 1) {
		if (i * A1 < A_B) {
			if (i < A1) {
				break;
			}
			++count;
			++A1;
		}
		--i;
	}

	std::cout << (A - 1 + i + count) << '\n';
}

int main()
{
	int Q;
	std::cin >> Q;

	for (int i = 0; i < Q; ++i) {
		int A, B;
		std::cin >> A >> B;
		calc(A, B);
	}

	std::cin >> Q;

	return 0;
}

Submission Info

Submission Time
Task D - Worst Case
User tomomo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 535 Byte
Status TLE
Exec Time 2103 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 1
AC × 5
TLE × 7
Set Name Test Cases
Sample s1.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, s1.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt TLE 2103 ms 256 KB
04.txt TLE 2103 ms 256 KB
05.txt TLE 2103 ms 384 KB
06.txt AC 1 ms 256 KB
07.txt TLE 2103 ms 256 KB
08.txt TLE 2103 ms 256 KB
09.txt TLE 2103 ms 256 KB
10.txt TLE 2103 ms 256 KB
11.txt AC 1 ms 256 KB
s1.txt AC 27 ms 256 KB