55722023-08-01 13:59:01111Mágikus táblázatcpp14Time limit exceeded 41/100600ms48992 KiB
#include <bits/extc++.h>
using namespace std;

#define int long long

#define pii pair<int, int>

signed main() {
#ifdef CB
	ifstream fin("be2.txt");
	cin.rdbuf(fin.rdbuf());
	ofstream fout("ki.txt");
#endif
	int A, B;
	cin >> A >> B;
	vector<int> a(A), b(B);
	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	vector<int> l(A);
	for (int i = 0; i < A; i++) {
		int c = 0;
		for (int j = 0; j < B; j++) {
			if (b[j] > a[i]) {
				l[i] = max(l[i], c);
				c = 0;
			}
			else {
				c++;
			}
		}
		l[i] = max(l[i], c);
	}
	int ans = 0;
	for (int i = 0; i < A; i++) {
		int mi = i;
		for (int j = i; j < A; j++) {
			if (a[j] < a[mi]) {
				mi = j;
			}
			ans = max(ans, (j - i + 1) * l[mi]);
		}
	}
	cout << ans << endl;
	return 0;
}























SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Time limit exceeded508ms2644 KiB
subtask214/14
3Accepted3ms2568 KiB
4Accepted3ms2524 KiB
5Accepted3ms2760 KiB
6Accepted3ms2912 KiB
7Accepted3ms3160 KiB
8Accepted3ms3164 KiB
subtask327/27
9Accepted9ms3576 KiB
10Accepted9ms3904 KiB
11Accepted8ms3836 KiB
12Accepted8ms4168 KiB
13Accepted6ms4268 KiB
14Accepted4ms4236 KiB
15Accepted7ms4400 KiB
16Accepted9ms4432 KiB
17Accepted10ms4508 KiB
subtask40/21
18Time limit exceeded554ms7024 KiB
19Time limit exceeded573ms8180 KiB
20Time limit exceeded550ms9088 KiB
21Time limit exceeded573ms10256 KiB
22Time limit exceeded564ms10468 KiB
23Time limit exceeded549ms11172 KiB
24Accepted9ms10024 KiB
subtask50/38
25Time limit exceeded600ms13604 KiB
26Time limit exceeded564ms15868 KiB
27Time limit exceeded546ms17932 KiB
28Time limit exceeded560ms19896 KiB
29Time limit exceeded556ms21928 KiB
30Time limit exceeded556ms23688 KiB
31Time limit exceeded556ms25704 KiB
32Time limit exceeded541ms26388 KiB
33Time limit exceeded569ms27640 KiB
34Time limit exceeded558ms29064 KiB
35Time limit exceeded569ms30044 KiB
36Time limit exceeded564ms33044 KiB
37Time limit exceeded532ms35200 KiB
38Time limit exceeded574ms37544 KiB
39Time limit exceeded560ms39484 KiB
40Time limit exceeded556ms41296 KiB
41Time limit exceeded572ms42756 KiB
42Time limit exceeded550ms44864 KiB
43Time limit exceeded537ms46700 KiB
44Time limit exceeded552ms48992 KiB