QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#94703#5608. Determining Nucleotide AssortmentsPetroTarnavskyi#RE 0ms0kbC++171.0kb2023-04-07 15:42:492023-04-07 15:42:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-07 15:42:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-04-07 15:42:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

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

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

const int N = 1047;
bitset<N> dp[2][N];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int c, n;
	cin >> c >> n;
	VI v(n);
	FOR (i, 0, n) cin >> v[i];
	dp[0][0] = 1;
	FOR(i, 0, n)
	{
		int b = (i + 1) % 2;
		FOR (k, 0, c + 1)
		{
			if (k + v[i] <= c)
				dp[b][k + v[i]] |= dp[b ^ 1][k];
			dp[b][k] |= dp[b ^ 1][k] << v[i];
		}
	}
	int a = -1, b = -1;
	int k = n % 2;
	FOR(i, 0, c + 1)
	{
		FOR(j, 0, c + 1)
		{
			if (dp[k][i][j])
			{
				if (a == -1 || ((a + b) < (i + j) || ((a + b == i + j) && a - b > i - j)))
					a = i, b = j;
			}
		}
	}
	cout << a << ' ' << b << '\n';
	return 0;
}

详细

Test #1:

score: 0
Dangerous Syscalls

input:

TATATGCTCT
3
1 10
6 10
6 6

output:


result: