Submission #339143

# Submission time Handle Problem Language Result Execution time Memory
339143 2020-12-24T16:38:53 Z cheissmart Table Tennis (info1cup20_tabletennis) C++14
0 / 100
87 ms 4072 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	vi a(n + k);
	for(int i = 0; i < n + k; i++) cin >> a[i];
	for(int left = 0; left <= k; left++) {
		for(int right = 0; right + left <= k; right++) {
			int l = left + 1, r = n + k - right - 1;
			int sum = a[l] + a[r];
			vi ans;
			while(l < r && ans.size() < n) {
				if(a[l] + a[r] == sum) {
					ans.PB(l + 1);
					ans.PB(r + 1);
					l++, r--;
				}
				else if(a[l] + a[r] < sum) l++;
				else r--;
			}
			sort(ALL(ans));
			if(ans.size() == n) {
				for(int i:ans) cout << i << " ";
				cout << endl;
				return 0;
			}
		}
	}

}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:33:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |    while(l < r && ans.size() < n) {
      |                   ~~~~~~~~~~~^~~
tabletennis.cpp:43:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |    if(ans.size() == n) {
      |       ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 844 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4072 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -