QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#772753 | #5146. Skills | songszh | WA | 59ms | 478096kb | C++14 | 3.9kb | 2024-11-22 21:35:16 | 2024-11-22 21:35:17 |
Judging History
answer
#include <bits/stdc++.h>
// #define int long long
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define rep(i,l,r) for (int i = (int)(l); i <= (int)(r); ++ i )
#define rep1(i,l,r) for (int i = (int)(l); i >= (int)(r); -- i )
#define il inline
#define fst first
#define snd second
#define ptc putchar
#define Yes ptc('Y'),ptc('e'),ptc('s'),puts("")
#define No ptc('N'),ptc('o'),puts("")
#define YES ptc('Y'),ptc('E'),ptc('S'),puts("")
#define NO ptc('N'),ptc('O'),puts("")
#define pb emplace_back
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define get(x) ((x - 1) / len + 1)
#define debug() puts("------------")
using namespace std;
typedef pair<int,int> PII;
typedef pair<int,PII> PIII;
typedef pair<ll,ll> PLL;
namespace szhqwq {
template<class T> il void read(T &x) {
x = 0; T f = 1; char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
x *= f;
}
template<class T,class... Args> il void read(T &x,Args &...x_) { read(x); read(x_...); }
template<class T> il void print(T x) {
if (x < 0) ptc('-'), x = -x;
if (x > 9) print(x / 10); ptc(x % 10 + '0');
}
template<class T,class T_> il void write(T x,T_ ch) { print(x); ptc(ch); }
template<class T,class T_> il void chmax(T &x,T_ y) { x = max(x,y); }
template<class T,class T_> il void chmin(T &x,T_ y) { x = min(x,y); }
template<class T,class T_,class T__> il T qmi(T a,T_ b,T__ p) {
T res = 1; while (b) {
if (b & 1) res = res * a % p;
a = a * a % p; b >>= 1;
} return res;
}
template<class T> il T gcd(T a,T b) { if (!b) return a; return gcd(b,a % b); }
template<class T,class T_> il void exgcd(T a, T b, T_ &x, T_ &y) {
if (b == 0) { x = 1; y = 0; return; }
exgcd(b,a % b,y,x); y -= a / b * x; return ;
}
template<class T,class T_> il T getinv(T x,T_ p) { T inv,y; exgcd(x,(T)p,inv,y); inv = (inv + p) % p; return inv; }
} using namespace szhqwq;
const int N = 1002,inf = 1e9,mod = 998244353;
const ull base = 131,base_ = 233;
const ll inff = 1e18;
int n,a[N][3];
int f[N][201][201],g[N][201][201],h[N][201][201];
il int p(int x) {
return !x ? x : x + 1;
}
il void solve() {
//------------code------------
read(n);
rep(i,1,n) read(a[i][0],a[i][1],a[i][2]);
memset(f,-1,sizeof f); memset(g,-1,sizeof g); memset(h,-1,sizeof h);
f[0][0][0] = g[0][0][0] = h[0][0][0] = 0;
rep(i,0,n - 1)
rep(j,0,200)
rep(k,0,200) {
if (~f[i][j][k]){
chmax(f[i + 1][p(j)][p(k)],f[i][j][k] + a[i + 1][0] - p(j) - p(k));
chmax(g[i + 1][1][p(j)],f[i][j][k] + a[i + 1][1] - p(j) - 1);
chmax(h[i + 1][1][p(k)],f[i][j][k] + a[i + 1][2] - p(k) - 1);
}
if (~g[i][j][k]) {
chmax(f[i + 1][1][p(k)],g[i][j][k] + a[i + 1][0] - 1 - p(k));
chmax(g[i + 1][p(j)][p(k)],g[i][j][k] + a[i + 1][1] - p(j) - p(k));
chmax(h[i + 1][p(j)][1],g[i][j][k] + a[i + 1][2] - p(j) - 1);
}
if (~h[i][j][k]) {
chmax(f[i + 1][p(j)][1],h[i][j][k] + a[i + 1][0] - 1 - p(j));
chmax(g[i + 1][p(k)][1],h[i][j][k] + a[i + 1][1] - p(k) - 1);
chmax(h[i + 1][p(j)][p(k)],h[i][j][k] + a[i + 1][2] - p(j) - p(k));
}
}
int ret = 0;
rep(j,0,200) rep(k,0,200) chmax(ret,max({f[n][j][k],g[n][j][k],h[n][j][k]}));
write(ret,'\n');
return ;
}
il void init() {
return ;
}
signed main() {
// init();
int _ = 1;
read(_);
while (_ -- ) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 59ms
memory: 478024kb
input:
2 3 1 1 10 1 10 1 10 1 1 5 1 2 3 6 5 4 7 8 9 12 11 10 13 14 15
output:
26 41
result:
ok 2 number(s): "26 41"
Test #2:
score: -100
Wrong Answer
time: 32ms
memory: 478096kb
input:
1 200 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 6323 6099 757 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 8596 825 7437 6098...
output:
1505370
result:
wrong answer 1st numbers differ - expected: '1505431', found: '1505370'