답안 #1072463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072463 2024-08-23T19:27:50 Z vjudge1 메기 농장 (IOI22_fish) C++17
0 / 100
881 ms 2097152 KB
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx2")
// #pragma GCC target("popcnt")
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
 
#define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
 
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)

bool cmin(int &a, int b){if(b<a){a=b;return 1;}return 0;}
bool cmax(int &a, int b){if(b>a){a=b;return 1;}return 0;}
void valid(ll in){cout<<((in)?"YES\n":"NO\n");}
ll lcm(ll a, ll b){return (a/gcd(a,b))*b;}
ll gauss(ll n){return (n*(n+1))/2;}
const int N = 307;
ll dp[N][N][N], pfmx[N][N][N], sfmx[N][N][N], mx[N];
ll max_weights(int n,int m,vi x,vi y,vi w){
    vector<vll> arr(n+4, vll(n+4, 0)), pf(n+4, vll(n+4, 0));
    fo(i, m) x[i]++, y[i]++;
    fo(i, m) arr[x[i]][y[i]] = w[i];
    fore(i, 1, n+1) {
        fore(j, 1, n+1) {
            pf[i][j] = (i ? pf[i][j-1] : 0) + arr[i][j];
        }
    }
    auto gets = [&](int i,int l,int r) {
        if(l > r) return 0ll;
        assert(l >= 1);
        return pf[i][r] - pf[i][l-1];
    };
    ll ans = 0;
    fore(i, 2, n+1){
        // j = i-1
        fo(c, n+1){
            fo(d, n+1){
                // e >= c no cambio nada
                dp[i][c][d] = max(dp[i][c][d], sfmx[i-1][d][c]);
                // e < c quito la suma anterior agrego c
                if(d+1 <= c) {
                    dp[i][c][d] = max(dp[i][c][d], pfmx[i-1][d][c-1] + gets(i-1, d+1, c));
                }else dp[i][c][d] = max(dp[i][c][d], sfmx[i-1][d][0]);
            }
        }
        // j = i-2
        if(i-2 >= 1){
            fo(c, n+1) {
                fo(d, n+1) {
                    dp[i][c][0] = max(dp[i][c][0], sfmx[i-2][d][0] + gets(i-1, 1, max(c, d)));
                }
            }
        }
        forex(j, i-3, 1){
            fo(c, n+1){
                dp[i][c][0] = max(dp[i][c][0], mx[j] + gets(i-1, 1, c));
            }
        }

        fo(d, n+1){
            pfmx[i][d][0] = dp[i][d][0];
            fore(e, 1, n+1){
                pfmx[i][d][e] = max(pfmx[i][d][e-1], dp[i][d][e] - gets(i,d+1,e));
            }
            ffo(e, n){
                sfmx[i][d][e] = max(sfmx[i][d][e+1], dp[i][d][e]);
            }
            mx[i] = max(mx[i],sfmx[i][d][0]);
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 881 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 847 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 847 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 881 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -