#include "fish.h"
#include <bits/stdc++.h>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) (x).begin(), (x).end()
#define len(x) (ll) x.size()
#define popcnt __builtin_popcount
#define pb push_back
#define pf push_front
#define eb emplace_back
#define F first
#define S second
#define ins insert
#define md (tl + tr) / 2
#define TL v + v, tl, md
#define TR v + v + 1, md + 1, tr
#define Tl t[v].l, tl, md
#define Tr t[v].r, md + 1, tr
#define yes cout << "YES\n";
#define no cout << "NO";
// #define int long long
#define bint __int128
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
const int N = 1e6 + 7;
const int M = 1e9 + 7;
const ll INF = 1e18 + 7;
const bint inf = 1e21;
struct segment{int t;int l; int r;};
int sq;
bool cmp(segment a, segment b) {
if (a.t / sq != b.t / sq)
return a.t < b.t;
if (a.l / sq != b.l / sq)
return a.l < b.l;
return a.r < b.r;
}
int dx[8] = {0, 1, 0, -1, -1, 1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int mod(int a, int b = M) {
if (a < 0)
a = b + a % b;
return a % b;
}
int binpow(int a, int n, int m = M) {
if (n == 0)
return 1 % m;
if (n & 1)
return a * binpow(a, n - 1, m) % m;
int x = binpow(a, n / 2, m);
return x * x % m;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random(int l,int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
int n, m;
ll dp[N][3], c[N], x[N], y[N], w[N];
ll max_weights(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
n = N, m = M;
for (int i = 1;i <= m;i++) {
x[i] = X[i - 1];
y[i] = Y[i - 1];
w[i] = W[i - 1];
c[x[i]] += w[i];
}
dp[0][0] = -INF;
for (int i = 1;i <= n;i++) {
dp[i][0] = dp[i - 1][1];
dp[i][1] = max(dp[i - 1][0] + c[i - 1], dp[i - 1][2]);
dp[i][2] = max(dp[i - 1][2], dp[i][1]);
}
return dp[n][2];
}
// void solve() {
// }
// signed main(){
// ios
// int test = 1;
// // cin >> test;
// while (test--) {
// solve();
// // cout << '\n';
// }
// return 0;
// }
# | 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... |
# | 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... |