Submission #75822961


Source Code Expand

#include <iostream>
#include<vector>

using namespace std;

int N;
vector<pair<int, int>> SC;
long long Ssum = 0, Csum = 0;

pair<int, int> func(int start = 0,int last=N) {
	if (start == last)
		return { 0,0 };
	if (start + 1 == last)
		return SC[start];
	int mid=0,midin=SC[mid].first,m;
	for (int i = start; last > i; ++i) {
		m = min(SC[i].first, SC[i].second);
		if(midin>m)
			mid = i, midin= m;
	}
	pair<int, int> p1=func(start,mid), p2=func(mid,last);
	int s1 = max(p1.first, p2.first),
		c1 = min(p1.second, p2.second),
		s2 = min(p1.first, p2.first),
		c2 = max(p1.second, p2.second);
	if ((Ssum - s1) * (Csum - c1) < (Ssum - s2) * (Csum - c2))
		return { s1,c1 };
	else
		return { s2,c2 };
}

int main() {
	cin >> N;
	int s, c;
	for (int i = 0; N > i; ++i) {
		cin >> s >> c;
		SC.push_back({ s,c });
		Ssum += s;
		Csum += c;
	}

	pair<int,int> P = func();
	
	cout << (Ssum - P.first) * (Csum - P.second);
}

Submission Info

Submission Time
Task B - SCSC Card Game
User auaahks
Language C++23 (GCC 15.2.0)
Score 0
Code Size 962 Byte
Status TLE
Exec Time > 2000 ms
Memory > 1048576 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
MLE × 1
AC × 2
TLE × 21
MLE × 33
Set Name Test Cases
Sample 00-sample-001.txt
All 00-sample-001.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt, 01-043.txt, 01-044.txt, 01-045.txt, 01-046.txt, 01-047.txt, 01-048.txt, 01-049.txt, 01-050.txt, 01-051.txt, 01-052.txt, 01-053.txt, 01-054.txt, 01-055.txt
Case Name Status Exec Time Memory
00-sample-001.txt MLE 684 ms > 1048576 KiB
01-001.txt MLE 694 ms > 1048576 KiB
01-002.txt MLE 691 ms > 1048576 KiB
01-003.txt MLE 780 ms > 1048576 KiB
01-004.txt MLE 987 ms > 1048576 KiB
01-005.txt MLE 686 ms > 1048576 KiB
01-006.txt MLE 650 ms > 1048576 KiB
01-007.txt MLE 815 ms > 1048576 KiB
01-008.txt MLE 897 ms > 1048576 KiB
01-009.txt MLE 774 ms > 1048576 KiB
01-010.txt MLE 1387 ms > 1048576 KiB
01-011.txt MLE 680 ms > 1048576 KiB
01-012.txt MLE 773 ms > 1048576 KiB
01-013.txt MLE 724 ms > 1048576 KiB
01-014.txt MLE 752 ms > 1048576 KiB
01-015.txt MLE 694 ms > 1048576 KiB
01-016.txt AC 11 ms 3276 KiB
01-017.txt MLE 653 ms > 1048576 KiB
01-018.txt MLE 654 ms > 1048576 KiB
01-019.txt TLE > 2000 ms 22876 KiB
01-020.txt TLE > 2000 ms 22812 KiB
01-021.txt TLE > 2000 ms 22696 KiB
01-022.txt TLE > 2000 ms 22876 KiB
01-023.txt TLE > 2000 ms 22728 KiB
01-024.txt TLE > 2000 ms 22592 KiB
01-025.txt TLE > 2000 ms 22748 KiB
01-026.txt TLE > 2000 ms 22584 KiB
01-027.txt TLE > 2000 ms 41988 KiB
01-028.txt AC 1 ms 3348 KiB
01-029.txt MLE 681 ms > 1048576 KiB
01-030.txt MLE 667 ms > 1048576 KiB
01-031.txt MLE 720 ms > 1048576 KiB
01-032.txt MLE 718 ms > 1048576 KiB
01-033.txt MLE 719 ms > 1048576 KiB
01-034.txt MLE 694 ms > 1048576 KiB
01-035.txt MLE 648 ms > 1048576 KiB
01-036.txt MLE 694 ms > 1048576 KiB
01-037.txt MLE 656 ms > 1048576 KiB
01-038.txt MLE 727 ms > 1048576 KiB
01-039.txt MLE 726 ms > 1048576 KiB
01-040.txt MLE 729 ms > 1048576 KiB
01-041.txt MLE 847 ms > 1048576 KiB
01-042.txt MLE 854 ms > 1048576 KiB
01-043.txt MLE 840 ms > 1048576 KiB
01-044.txt TLE > 2000 ms 856240 KiB
01-045.txt TLE > 2000 ms 851888 KiB
01-046.txt TLE > 2000 ms 855672 KiB
01-047.txt TLE > 2000 ms 22560 KiB
01-048.txt TLE > 2000 ms 22448 KiB
01-049.txt TLE > 2000 ms 22424 KiB
01-050.txt TLE > 2000 ms 22336 KiB
01-051.txt TLE > 2000 ms 22572 KiB
01-052.txt TLE > 2000 ms 22344 KiB
01-053.txt TLE > 2000 ms 22344 KiB
01-054.txt TLE > 2000 ms 22472 KiB
01-055.txt TLE > 2000 ms 22684 KiB