Submission #475191

# Submission time Handle Problem Language Result Execution time Memory
475191 2021-09-21T11:45:49 Z bigo Table Tennis (info1cup20_tabletennis) C++14
0 / 100
70 ms 884 KB
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>vec(n + k);
	for (int i = 0; i < n + k; i++)
		cin >> vec[i];
	int ans=1;
	int max1 = 0;
	int pla;
	vector<bool>vec1(n + k, false);
	for (int i = 0; i < n + k - 1; i++) {
		if (vec[i + 1] == vec[i] + 1) {
			ans++;
			max1 = max(max1, ans);
			vec1[i] = true;
			vec1[i + 1] = true;
		}
		else
			ans = 1;
	}
	max1 = min(max1, n);
	int cnt = 0;
	for (int i = 0; i < max1; i++) {
		if (vec1[i])
			cnt++;
	}
	if (cnt == max1) {
		for (int j = 0; j <= max1 - 1; j++)
			cout << vec[j] << " ";
	}
	else {
		for (int i = 1; i <= n + k - max1; i++) {
			if (vec1[i - 1])
				cnt--;
			if (vec1[i + max1 - 1])
				cnt++;
			if (cnt == max1) {
				for (int j = i; j <= i + max1 - 1; j++)
					cout << vec[j] << " ";
				break;
			}
		}
	}
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:12:6: warning: unused variable 'pla' [-Wunused-variable]
   12 |  int pla;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 368 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 884 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -