| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 721992 | TimDee | Homecoming (BOI18_homecoming) | C++17 | 47 ms | 37328 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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
vector<pi> dp(N+1,{-inf,0});
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];
forn(i,N) {
dp[i+1].f = max(dp[i].f+b[i+K-1],dp[i].s+pr[i+K]-pr[i]);
dp[i+1].s = max(dp[i].f,dp[i].s);
}
return max(dp[N].f,dp[N].s);
#undef int
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
