QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#558303 | #8936. Team Arrangement | Yarema# | WA | 0ms | 3892kb | C++20 | 1.4kb | 2024-09-11 15:22:18 | 2024-09-11 15:22:18 |
Judging History
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 vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int INF = 1e9;
const int N = 74;
int dp[N][N];
void updMax(int& a, int b)
{
a = max(a, b);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
FOR (i, 0, N) fill(dp[i], dp[i] + N, -2 * INF);
int n;
cin >> n;
vector<PII> a(n);
FOR (i, 0, n)
cin >> a[i].F >> a[i].S;
VI w(n);
FOR (i, 0, n)
cin >> w[i];
vector<vector<PII>> f(n + 1);
dp[1][0] = 0;
FOR (i, 1, n + 1)
{
FOR (j, 0, n)
if (a[j].F <= i)
f[i].PB(a[j]);
sort(ALL(f[i]), [](PII& p1, PII& p2)
{
return p1.S < p2.S;
});
}
FOR (x, 1, n + 1)
{
FOR (used, 0, n + 1)
{
if (used == SZ(f[x]) || f[x][used].S > x)
updMax(dp[x + 1][used], dp[x][used]);
if (used + x <= SZ(f[x]))
updMax(dp[x][used + x], dp[x][used] + w[x - 1]);
}
}
//cerr << dp[n][n] << '\n';
if (dp[n][n] < -INF)
cout << "impossible\n";
else
cout << dp[n][n] << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 1 3 3 3 2 3 1 1 100
output:
100
result:
ok single line: '100'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
9 1 4 2 5 3 4 1 5 1 1 2 5 3 5 1 3 1 1 1 1 1 1 1 1 1 1 1
output:
6
result:
ok single line: '6'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
14 3 3 1 2 2 3 2 3 2 3 1 1 2 3 1 3 3 3 1 3 1 3 1 2 2 3 1 3 -9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573
output:
-16558567
result:
ok single line: '-16558567'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
14 1 2 1 4 2 3 3 5 4 5 2 5 2 4 2 4 1 2 3 4 1 5 2 4 1 1 4 5 -13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167
output:
-2673021
result:
ok single line: '-2673021'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3704kb
input:
14 2 3 4 4 1 7 3 6 3 4 1 1 1 4 4 7 3 7 1 7 2 3 6 6 1 1 3 6 2923142 1686477 640352 2848353 9202543 -4441381 4866381 -3610520 8124124 -1372894 1111310 -7538627 466143 9937961
output:
10814681
result:
wrong answer 1st lines differ - expected: '5939733', found: '10814681'