5572 | 2023-08-01 13:59:01 | 111 | Mágikus táblázat | cpp14 | Time limit exceeded 41/100 | 600ms | 48992 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Time limit exceeded | 508ms | 2644 KiB | ||||
subtask2 | 14/14 | ||||||
3 | Accepted | 3ms | 2568 KiB | ||||
4 | Accepted | 3ms | 2524 KiB | ||||
5 | Accepted | 3ms | 2760 KiB | ||||
6 | Accepted | 3ms | 2912 KiB | ||||
7 | Accepted | 3ms | 3160 KiB | ||||
8 | Accepted | 3ms | 3164 KiB | ||||
subtask3 | 27/27 | ||||||
9 | Accepted | 9ms | 3576 KiB | ||||
10 | Accepted | 9ms | 3904 KiB | ||||
11 | Accepted | 8ms | 3836 KiB | ||||
12 | Accepted | 8ms | 4168 KiB | ||||
13 | Accepted | 6ms | 4268 KiB | ||||
14 | Accepted | 4ms | 4236 KiB | ||||
15 | Accepted | 7ms | 4400 KiB | ||||
16 | Accepted | 9ms | 4432 KiB | ||||
17 | Accepted | 10ms | 4508 KiB | ||||
subtask4 | 0/21 | ||||||
18 | Time limit exceeded | 554ms | 7024 KiB | ||||
19 | Time limit exceeded | 573ms | 8180 KiB | ||||
20 | Time limit exceeded | 550ms | 9088 KiB | ||||
21 | Time limit exceeded | 573ms | 10256 KiB | ||||
22 | Time limit exceeded | 564ms | 10468 KiB | ||||
23 | Time limit exceeded | 549ms | 11172 KiB | ||||
24 | Accepted | 9ms | 10024 KiB | ||||
subtask5 | 0/38 | ||||||
25 | Time limit exceeded | 600ms | 13604 KiB | ||||
26 | Time limit exceeded | 564ms | 15868 KiB | ||||
27 | Time limit exceeded | 546ms | 17932 KiB | ||||
28 | Time limit exceeded | 560ms | 19896 KiB | ||||
29 | Time limit exceeded | 556ms | 21928 KiB | ||||
30 | Time limit exceeded | 556ms | 23688 KiB | ||||
31 | Time limit exceeded | 556ms | 25704 KiB | ||||
32 | Time limit exceeded | 541ms | 26388 KiB | ||||
33 | Time limit exceeded | 569ms | 27640 KiB | ||||
34 | Time limit exceeded | 558ms | 29064 KiB | ||||
35 | Time limit exceeded | 569ms | 30044 KiB | ||||
36 | Time limit exceeded | 564ms | 33044 KiB | ||||
37 | Time limit exceeded | 532ms | 35200 KiB | ||||
38 | Time limit exceeded | 574ms | 37544 KiB | ||||
39 | Time limit exceeded | 560ms | 39484 KiB | ||||
40 | Time limit exceeded | 556ms | 41296 KiB | ||||
41 | Time limit exceeded | 572ms | 42756 KiB | ||||
42 | Time limit exceeded | 550ms | 44864 KiB | ||||
43 | Time limit exceeded | 537ms | 46700 KiB | ||||
44 | Time limit exceeded | 552ms | 48992 KiB |