QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94703 | #5608. Determining Nucleotide Assortments | PetroTarnavskyi# | RE | 0ms | 0kb | C++17 | 1.0kb | 2023-04-07 15:42:49 | 2023-04-07 15:42:51 |
Judging History
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