QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328119#8046. Rock-Paper-Scissors PyramidPetroTarnavskyi#Compile Error//C++201.8kb2024-02-15 17:24:582024-02-15 17:25:00

Judging History

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

  • [2024-02-15 17:25:00]
  • 评测
  • [2024-02-15 17:24:58]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int N = 200'447;
const int K = 11;

int dp[N][K][K];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	VI a(n), b(n);
	FOR (i, 0, n) cin >> a[i];
	FOR (i, 0, n) cin >> b[i];
	
	sort(ALL(a), greater());
	sort(ALL(b), greater());
	
	RFOR (i, 2 * n + 1, 1)
	{
		FOR (k1, 0, k + 1)
		{
			FOR (k2, 0, k + 1)
			{
				if (i & 1)
				{
					int cnt = i / 2;
					int j = cnt - k2 + k1;
					if (k1 > 0 && j < n)
						dp[i - 1][k1 - 1][k2] = max(dp[i - 1][k1 - 1][k2], dp[i][k1][k2] + a[j - 1]);
					if (cnt - k1 + k2 < n || k1 >= cnt)
						dp[i - 1][k1][k2] = max(dp[i - 1][k1][k2], dp[i][k1][k2]);
				}
				else
				{
					int cnt = i / 2;
					int j = cnt - k1 + k2;
					if (k2 > 0 && j < n)
						dp[i - 1][k1][k2 - 1] = min(dp[i - 1][k1][k2 - 1], dp[i][k1][k2] - b[j - 1]);
					if (cnt - k2 + k1 < n || k2 >= cnt)
						dp[i - 1][k1][k2] = min(dp[i - 1][k1][k2], dp[i][k1][k2]);
				}
			}
		}
	}
	RFOR (i, 2 * n + 1, 0)
	{
		FOR (k1, 0, k + 1)
		{
			FOR (k2, 0, k + 1)
			{
				cerr << i << ' ' << k1 << ' ' << k2 << ' ' << dp[i][k1][k2] << '\n';
			}
		}
	}
	cout << dp[0][0][0] << '\n';	
	return 0;
}
4 0 0 0
4 0 1 0
4 1 0 0
4 1 1 0
3 0 0 0
3 0 1 0
3 1 0 0
3 1 1 0
2 0 0 0
2 0 1 1
2 1 0 0
2 1 1 0
1 0 0 0
1 0 1 0
1 1 0 -100
1 1 1 0
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0

Details

answer.code:78:1: error: expected unqualified-id before numeric constant
   78 | 4 0 0 0
      | ^