QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775023#5035. foo~NineSuns0 147ms93416kbC++141.2kb2024-11-23 14:31:312024-11-23 14:31:32

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 14:31:32]
  • 评测
  • 测评结果:0
  • 用时:147ms
  • 内存:93416kb
  • [2024-11-23 14:31:31]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back

using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 6e5+5, K = 35;  
int n, k, f[K][N], a[N], ans, stk[N], ed, mx[N], c[N]; 

void sol () {
	memset(f, -0x3f, sizeof f); 
	f[0][0] = 0; 
	for (int i = 1;i <= k;i++) {
		ed = 0; 
		for (int j = 1;j <= n;j++) {
			mx[j] = a[j]; c[j] = 0; 
			for (int z = j-1;z >= 1 && mx[z] < a[j];z--) mx[z] = a[j], c[z]++; 
			while (ed && a[stk[ed]] < a[j]) ed--; 
			stk[++ed] = j; 
			for (int z = 1;z <= j;z++) f[i][j] = max(f[i][j], f[i-1][z-1]+c[z]); 
//			cout << j << " " << ed << endl; 
			for (int z = ed;z >= 1;z--) {
				for (int p = stk[z];p > stk[z-1];p--) f[i][j] = max(f[i][j], f[i-1][p-1]+ed-z+1); 
			}
		}
	}
	for (int i = 1;i <= n;i++) ans = max(ans, f[k][i]); 
}

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> k; 
	for (int i = 1;i <= n;i++) cin >> a[i]; 
	for (int i = 1;i <= n;i++) 
		if (a[i] == n) {
			rotate(a+1, a+i, a+1+n); break; 
		}
	sol(); 
	reverse(a+1, a+1+n); rotate(a+1, a+n, a+1+n); 
	sol();
	cout << ans;  
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 88892kb

input:

23 6
16 20 22 4 21 10 3 7 5 8 15 12 9 1 6 17 23 13 11 19 18 14 2

output:

18

result:

wrong answer 1st words differ - expected: '20', found: '18'

Subtask #2:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

93943 1
87243 48984 50611 19218 77699 25025 85769 28141 13380 34875 42459 66419 53472 4367 48292 16894 92171 87263 42527 67085 30687 29235 27515 81053 31421 34864 83591 70491 75344 7026 50250 63402 26773 5330 36308 76399 80032 15501 16205 71750 73964 67876 68901 70548 2043 79979 89479 19784 38838 44...

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 147ms
memory: 93416kb

input:

1992 25
144 612 1315 1966 1779 1773 1529 625 36 1849 1783 1441 1388 1558 1258 724 137 397 542 353 1162 1213 406 792 1317 882 994 298 1864 1969 103 449 508 1501 89 1721 195 778 657 222 1152 1780 613 743 1206 694 829 142 69 1973 1465 1343 655 1540 155 146 350 491 759 1695 1082 1357 1329 1745 232 1850 ...

output:

230

result:

wrong answer 1st words differ - expected: '237', found: '230'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%