QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#168347 | #7072. Photograph | supepapupu# | WA | 1ms | 3844kb | C++17 | 1.2kb | 2023-09-08 10:42:55 | 2023-09-08 10:42:55 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e4 + 10, INF = 0x3f3f3f3f, mod = 998244353;
inline int read() {
int f = 1, k = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
k = k * 10 + c - '0';
c = getchar();
}
return f * k;
}
int n;
int a[N], f[N], dp[N];
int main() {
// ios::sync_with_stdio(0); cin.tie(0);
n = read();
for (int i = 1; i <= n; ++i) a[i] = read();
for (int k = 1; k <= n; ++k) {
int g = -a[k];
int h = a[k];
for (int i = 1; i <= k; ++i) f[i] = 0;
// cout << "k:" << k << el;
for (int i = k + 1; i <= n; ++i) {
f[i] = max(dp[i - 1], (f[i - 1], max(g + a[i], h - a[i])));
g = max(g, dp[i - 1] - a[i]);
h = max(h, dp[i - 1] + a[i]);
// cout << f[i] << " \n"[i == n];
}
printf("%d\n", f[n]);
swap(f, dp);
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3844kb
input:
5 4 1 2 3 4 5 1 2 3 4 5 6 6 8 10
output:
3 5 4 3 0
result:
wrong answer 1st lines differ - expected: '10', found: '3'