QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620732 | #3558. Constellation 3 | Dimash# | 0 | 3ms | 14968kb | C++23 | 1.3kb | 2024-10-07 20:50:07 | 2024-10-07 20:50:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3 + 12, MOD = (int)1e9 + 7;
#define int ll
int n, m, a[N], x[N], y[N], c[N][N], sf[N][N];
ll mx[N][N];
ll dp[N][N], s[N];
void test() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
a[i] = n - a[i];
}
cin >> m;
ll f = 0;
for(int i = 1; i <= m; i++) {
cin >> x[i] >> y[i];
y[i] = n - y[i] + 1;
cin >> c[x[i]][y[i]];
f += c[x[i]][y[i]];
}
for(int i = 1; i <= n; i++) {
for(int j = a[i]; j >= 1; j--) {
sf[i][j] = max(sf[i][j + 1], c[i][j]);
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= a[i]; j++) {
dp[i][j] = dp[i][j - 1];
if(a[i - 1] >= j) {
dp[i][j] = max(dp[i][j], (ll)sf[i - 1][a[i] + 1] + dp[i - 1][j]);
} else {
dp[i][j] = max(dp[i][j], s[i - 1]);
}
s[i] = max(s[i], dp[i][j] + c[i][j]);
}
s[i] = max(s[i - 1], s[i]);
}
cout << f -s[n] << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 14968kb
input:
297 296 275 40 154 200 77 201 106 133 163 127 268 225 154 27 202 272 176 133 116 151 11 262 281 188 152 249 53 133 106 160 62 104 210 54 201 184 110 199 217 155 193 168 239 277 22 230 187 201 14 85 100 159 129 69 241 150 10 20 263 285 76 219 52 40 241 126 182 23 55 243 145 203 163 251 243 13 292 249...
output:
4895411
result:
wrong answer 1st lines differ - expected: '4354552', found: '4895411'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%