Submission #724564

# Submission time Handle Problem Language Result Execution time Memory
724564 2023-04-15T14:29:10 Z TimDee Homecoming (BOI18_homecoming) C++17
0 / 100
1000 ms 52952 KB
//   you're already the best
//             _
//   ^ ^      //
// >(O_O)<___//
//   \ __ __  \
//    \\ \\ \\\\

#include "homecoming.h"
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

using ll = long long;
//#define int long long
//#define double long double
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second 
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e18;
const int mod = 998244353;

long long solve(int N, int K, int *A, int *B) {
    #define int long long
    const int inf = 1e18;

    vector<int> b;
    forn(i,N) b.pb(B[i]);
    forn(i,N) b.pb(B[i]);
    vector<int> pr(2*N+1,0);
    forn(i,2*N) pr[i+1]=pr[i]+b[i];

    vector<int> a;
    forn(i,N) a.pb(A[i]);
    forn(i,N) a.pb(A[i]);
    vector<int> pra(2*N+1,0);
    forn(i,2*N) pra[i+1]=pra[i]+a[i];

    vector<int> dp(2*N+1,0);
    forn(i,K) cout<<dp[i]<<' ';
    for (int i=K; i<=2*N; ++i) {
        dp[i]=max(dp[i],dp[i-1]);
        int sub = (i>=N)?dp[i-N]:0;
        for (int j=max(0ll,i-N); j<=i-K; ++j) {
            dp[i]=max(dp[i],dp[j]-sub+(pra[i-K+1]-pra[j])-(pr[i]-pr[j]));
        }
    }
    return dp[2*N];

    #undef int
}

Compilation message

homecoming.cpp:5:1: warning: multi-line comment [-Wcomment]
    5 | //   \ __ __  \
      | ^
homecoming.cpp:28:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   28 | const int inf = 1e18;
      |                 ^~~~
homecoming.cpp: In function 'long long int solve(int, int, int*, int*)':
homecoming.cpp:33:15: warning: unused variable 'inf' [-Wunused-variable]
   33 |     const int inf = 1e18;
      |               ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 52952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -