QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#261229 | #7695. Double Up | WA_automaton | WA | 5ms | 19272kb | C++17 | 2.2kb | 2023-11-22 19:18:29 | 2023-11-22 19:18:29 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
void debug() {std::cerr << "\n";}
template<class T, class... OtherArgs>
void debug(T &&var, OtherArgs &&... args) {
std::cerr << std::forward<T>(var) << " ";
debug(std::forward<OtherArgs>(args)...);
}
#define SZ(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int N = 1010, M = 10000010;
const int P = 998244353;
LL powmod(LL a, LL b, LL p = P) {LL res = 1 % p; a %= p; assert(b >= 0); for(; b; b >>= 1) { if (b & 1) res = res * a % p; a = a * a % p; } return res; }
int n, m;
__int128 dp[N][N], a[N];
void read(__int128 &n){
__int128 x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
n = x * f;
}
void print(__int128 n){
if (n < 0) {
putchar('-');
n = -n;
}
if (n > 9) {
print(n / 10);
}
putchar(n % 10 + '0');
}
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) {
read(a[i]);
dp[i][i] = a[i];
}
for (int len = 2; len <= n; len++) {
for (int l = 1; l + len - 1 <= n; l++) {
int r = l + len - 1;
if (a[l] == dp[l + 1][r]) {
dp[l][r] = max(dp[l][r], dp[l + 1][r] * 2);
} else {
dp[l][r] = max(dp[l][r], max(dp[l + 1][r], a[l]));
}
if (a[r] == dp[l][r - 1]) {
dp[l][r] = max(dp[l][r], dp[l][r - 1] * 2);
} else {
dp[l][r] = max(dp[l][r], max(dp[l][r - 1], a[r]));
}
}
}
print(dp[1][n]);
}
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout << fixed << setprecision(20);
int _ = 1;
// cin >> _;
while (_--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 19272kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
2
result:
wrong answer 1st lines differ - expected: '512', found: '2'