solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 300100, MAXK = 105, INF = 0x3f3f3f3f;
int dp[MAX][MAXK];
int p[MAX], n;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &p[i]);
memset(dp, INF, sizeof dp);
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
int st = p[i] / 1000;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
const int INF = 1e9 + 7;
int a[N], dp[2][49];
inline int read() {
int s = 1, a = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') s = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
a = a * 10 + ch - '... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int dp[300009][205];
int arr[300009];
int main() {
int n;
scanf("%d", ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int a[N], n, f[N][35];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
memset(f, 0x3f, sizeof f);
f[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= 31; j++) {
if (a[i + 1] / 10... | 10 | CPP |
#include <bits/stdc++.h>
const int N = 3e5 + 10;
using namespace std;
int n, A[N];
int dp[2][35];
int main() {
memset(dp, 0x3f, sizeof(dp));
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &A[i]);
A[i] /= 100;
}
int s = 0, t = 1;
dp[0][0] = 0;
for (int i = 1; i <= n; ++i) {
int a =... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), (c > '9' ||... | 10 | CPP |
#include <bits/stdc++.h>
const int lim = 45;
const int N = 300005;
const int INF = 1000000000;
using namespace std;
int n, a[N];
int f[2][lim];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
int now = 0;
f[now][0] = 0;
for (int j = 1; j <= 40; ++j) f[now][j] = INF;
for (int i... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int B = 100;
int n, x;
int f[B + 1], g[B + 1];
int main() {
scanf("%d", &n);
memset(f, 127, sizeof(f));
f[0] = 0;
for (int i = 1; i <= n; ++i) {
scanf("%d", &x);
x /= 100;
memcpy(g, f, sizeof(g));
memset(f, 127, sizeof(f));
for (int j = 0; ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
if (a < b) {
return a;
}
return b;
}
long long max(long long a, long long b) {
if (a > b) {
return a;
}
return b;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long lo... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 300100;
long long n;
long long a[maxn];
long long p[maxn];
long long prv[maxn];
long long nex[maxn];
bool check(long long x) {
if (p[n] - x > x / 1000 * 100) return false;
long long i = lower_bound(p, p + n + 1, x) - p - 1;
long long A = x - p[i... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, a[300010], res[300010][55];
int dp(int id, int cs) {
if (id == n) return 0;
if (res[id][cs] != -1) return res[id][cs];
int tk = min(cs, a[id]);
int w = a[id] - tk + dp(id + 1, cs - tk);
if (cs < 50) w = min(w, a[id] + dp(id + 1, cs + a[id] / 10));
return ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long a[400010];
int main() {
long long n;
cin >> n;
long long sum = 0, count = 0;
for (long long i = 0; i < n; i++) {
scanf("%lld", &a[i]);
sum += (a[i] / 1000);
if (a[i] == 1000) count++;
}
long long tmp;
if (sum <= 11)
tmp = sum - a[n - ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 5, N2 = 100, inf = 1e18;
long long int ary[N];
long long int dp[N][N2 + 1];
long long int solve(long long int i, long long int b, long long int n) {
if (i == n) {
return 0;
}
if (dp[i][b] == -1) {
dp[i][b] = inf;
if (b + ary[i... | 10 | CPP |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 1e9;
vector<unordered_map<int, int> > fw;
int n, q;
int main() {
iostream::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> dp[2];
const int MX = 500 + 1;
for (int i = 0; i < 2... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, a[300300];
int dp[33][300300];
int calc(int bon, int ind) {
if (ind == n) return 0;
int &res = dp[bon][ind];
if (res != -1) return res;
res = a[ind] + ca... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
char ch;
bool flag = false;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-') flag = true;
for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
x = flag ? -x : x;
}
inline void read(long long &x) {
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e5 + 35;
const int INF = 1e9;
int a[MaxN];
int dp[MaxN][51];
inline void up(int& x, int y) {
if (x > y) x = y;
}
int n;
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
a... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int read() {
char c = getchar();
int d = 0, f = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') f = -1;
for (; c >= '0' && c <= '9'; d = d * 10 + c - 48, c = getchar())
;
return d * f;
}
const int N = 300010;
int n;
long long a[N], s[N], la[N], ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v1;
vector<int> v2;
int rest[300002 * 4];
int need[300002 * 4];
int ar[300002];
inline void init(int b, int l, int r) {
if (l + 1 == r) {
need[b] = ar[l];
return;
}
init(b * 2 + 1, l, (l + r) >> 1);
init(b * 2 + 2, (l + r) >> 1, r);
need... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
void setmin(int &a, int b) {
if (a > b) {
a = b;
}
}
int N;
int A[MAXN];
int dp[MAXN][200];
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%d", &A[i]);
}
memset(dp, 63, sizeof(dp));
dp[0][0] = 0;
for (i... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline int read(register int ans = 0, register int sgn = ' ',
register int ch = getchar()) {
for (; ch < '0' || ch > '9'; sgn = ch, ch = getchar())
;
for (; ch >= '0' && ch <= '9'; (ans *= 10) += ch - '0', ch = getchar())
;
return sgn - '-' ? a... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 19);
const int MAXV = (50);
const int inf = (int)2e9 + 42;
int n;
int a[MAXN];
void read() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] /= 100;
}
}
int dp[MAXV][2];
int add[MAXV];
void solve() {
add[10] = 1;
add[20] =... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
long long ret = n % m;
if (ret < 0) ret += m;
return ret;
}
long long gcd(long long a, long long b) {
return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
if (b == 0LL) ret... | 10 | CPP |
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const int MAXN = 300001;
const int DV = 100;
const int INF = 1000 * 1000 * 1000;
int a[MAXN];
int s = 0;
int ans = INF;
int lft(int x) { return s - x - x / 10; }
void tr(int x) {
ans = min(ans, x + max(0, lft(x)));
if (x + (... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 5, N2 = 50, inf = 1e18;
long long int ary[N];
long long int dp[N][N2 + 1];
long long int solve(long long int i, long long int b, long long int n) {
if (i == n) {
return 0;
}
if (dp[i][b] == -1) {
dp[i][b] = inf;
if (b + ary[i]... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 10;
const int INF = 1e9 + 7;
const double EPS = 1e-8;
int n, a[N];
int dp[N][102];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] /= 100;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= 50; j++) dp[i][j... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int N = 1e9 + 7;
void solve() {
long long int n;
cin >> n;
vector<long long int> a(n + 1);
for (long long int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<vector<long long int> > dp(n + 4, vector<long long int>(64, N));
dp[0][0] = 0;
for (long l... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m, ans, two, one, l, r, k, a[N], dp[N][31];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
a[i] /= 100;
}
memset(dp, 127, sizeof(dp));
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, a[300001], f[300001][55], ans = 2e9;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
memset(f, 60, sizeof f);
f[0][0] = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j <= 50; j++) {
f[i + 1][j + a[i + 1] / 1000] =
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, a[303030], sum, s[303030];
bool ok(int k) {
int x = k * 10, y = sum - k * 11, ans = x + y;
int xx = x, now = 1;
while (xx >= a[now]) {
xx -= a[now];
now++;
}
if (!xx) return 1;
for (int i = now; i <= n; i++)
if (a[i] == 10) {
if (y + s[n... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, a[N];
long long s[N];
int pre[3][N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
s[i] = s[i - 1] + a[i];
}
for (int i = 1; i <= n; ++i) {
pre[1][i] = pre[1][i - 1];
pre[2][i] = pre[2][... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
T sqr(const T &x) {
return x * x;
}
template <class T>
T lowbit(const T &x) {
return (x ^ (x - 1)) & x;
}
template <class T>
int countbit(const T &n) {
return (n == 0) ? 0 : (1 + countbit(n & (... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int inf = 1e9;
int n;
int a[maxn];
int dp[maxn][31];
inline void upd(int &x, int y) { x = min(x, y); }
int main() {
cin.tie();
ios::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i], a[i] /= 100;
for (int i = 0;... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int g[500000], h[500000], v[500000];
int i, k, l, n, s, t, t1, t2, t3, d1, d2;
int main() {
t = 1000000000;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &g[i]);
g[i] = g[i] / 1000;
}
for (i = 1; i <= n; i++)
if (g[i] == 2) t2++;
s = s + t2... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
if (y < x) x = y;
}
int dp[2][32];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= 31; i++) dp[0][i] =... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
inline void smin(P &a, Q b) {
if (b < a) a = b;
}
template <class P, class Q>
inline void smax(P &a, Q b) {
if (a < b) a = b;
}
const int maxn = 300000 + 100;
int n;
int a[maxn], sum;
int main() {
ios_base::sync_with_stdio(false);
cin.tie... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, a[303030], sum, s[303030];
bool ok(int k) {
int x = k * 10, y = sum - k * 11, ans = x + y;
int xx = x, now = 1;
while (xx >= a[now]) {
xx -= a[now];
now++;
}
if (!xx) return 1;
for (int i = now; i <= n; i++)
if (a[i] == 10) {
if (y + s[n... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
x = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
x *= 10;
x += c - '0';
c = getchar();
}
}
inline void reads(string& s) {
char c = getchar();
while (c... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1) * 4;
const long long oo = 1000000000;
const int N = 300010;
int n, a[N], mx = 0;
bool take[N];
bool tr() {
long long bonus = 0;
for (int i = 0; i < n; ++i) {
if (take[i]) {
bonus += a[i] / 10;
} else {
bonus -= min(bonus, (l... | 10 | CPP |
#include <bits/stdc++.h>
const int N = 300050;
const int M = 35;
const int inf = 1e9 + 7;
int dp[N][M], a[N];
int min(int a, int b) { return a > b ? b : a; }
int main() {
int n, i, j, k;
scanf("%i", &n);
for (i = 0; i <= n; i++)
for (j = 0; j < M; j++) dp[i][j] = inf;
dp[0][0] = 0;
for (i = 1; i <= n; i++... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline void chmin(int &x, int v) {
if (v < x) x = v;
}
const int M = 40;
int N;
int A[300000];
int dp[300001][M + 1];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 0; i < (N); i++) {
cin >> A[i];
A[i] /= 100;
}
for (in... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
int n;
int A[300010];
int dp[300010][41];
void Update(int &A, int B) {
if (A == -1)
A = B;
else if (A > B)
A = B;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &A[i]);
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 3e5 + 10;
const ll INF = 1e18;
void umax(ll &a, ll b) { a = max(a, b); }
ll n;
ll a[N];
ll dp[N][41];
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
for (ll i = 0; i < n; ++i) {
cin >> a[i];
a[i] /= 100;
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int a[N];
int one;
int two;
int n;
int calc(int cnt1, int cnt2) {
int res = 0;
int credit = 0;
for (int i = 0; i < n; ++i) {
if ((a[i] == 1000 && cnt1 > 0) || (a[i] == 2000 && cnt2 > 0)) {
credit += a[i] / 10;
res += a[i];
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), (c > '9' ||... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n), la1(n, -1), la2(n, -1);
vector<long long> pre(n, 0);
for (int i = 0; i < n; i++) {
cin >> a[i];
pre[i] = a[i];
if (i) pre[i] += pre[i - 1];
if (i) {
if (a[i - 1] == 1000) {
la1[i] = i - ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long dp[300005][35], n;
int ara[600005];
long long dp_func(int pos, int ase) {
if (pos > n) return 0;
if (dp[pos][ase] != -1) return dp[pos][ase];
long long ret = 21474836499999;
for (int i = 1; i <= ase && (ara[pos] >= i * 100); i++) {
ret = min(ret, dp_fu... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long dp[maxn][50];
int a[maxn];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
memset(dp, 63, sizeof dp);
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 50; j++) {
if (dp[i][j] > ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
long long ret = n % m;
if (ret < 0) ret += m;
return ret;
}
long long gcd(long long a, long long b) {
return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
if (b == 0LL) ret... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 312345;
const int INF = 0x3f3f3f3f;
int n;
int a[MAXN];
int psum[MAXN];
int rsum(int p, int q) {
if (q < p) return 0;
return psum[q + 1] - psum[p];
}
int sub(int p1, int b1, int p2, int b2) {
int cost = p1;
int bonus = p1 / 10;... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10, Max = 50, inf = 1e8;
int dp[maxn][Max], a[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 1; i < Max; i++) {
dp[0][i] = inf;
}
for (int i = 1; i <= n; i++) {
int x;
cin >> x... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dp[300005][35], a[300005];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
a[i] /= 100;
}
for (int i = 0; i <= n; i++)
for (int j = 0; j <= 30; j++) dp[i][j] = 1000000000;
dp[0][0] = 0;
for (int i = 0; i ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int a[300005];
int dp[300005][35];
int main() {
ios::sync_with_stdio(false);
int n, cur = 0, ans = 0x3f3f3f3f;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= 30; j++) {
dp[i][j] = 0x3f3f3... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long dp[300010][41];
int main() {
int N, A[300010];
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", A + i);
}
for (int i = 0; i <= N; i++)
for (int j = 0; j <= 40; j++) dp[i][j] = 2000000000000000000LL;
dp[0][0] = 0;
for (int i = 0; i <... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAXD = 50;
int n, a[300005];
long long f[300005][MAXD + 5];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i <= n; ++i) a[i] /= 100;
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= MAXD; ++j) f[i][j] = ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int max_n = 300033, max_m = 40, inf = 1011111111;
int n, a[max_n], dp[2][max_m];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
a[i] /= 100;
}
int q1 = 0, q2 = 1;
for (int j = 0; j < max_m; ++j) {
dp[q1][j] = inf;... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, sum, counter, a[300010];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
if (a[i] == 2000) counter++;
}
int temp = sum * 1 / 11;
temp -= (temp % 100);
if (sum <= 11000) temp = (sum - a[n]) / 10;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
int num[300003], dp[2][45];
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> num[i];
num[i] /= 100;
}
int now = 0;
memset(dp, 0x3f, sizeof(dp));
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
int a = num[i] / 10;
for (int j = 0... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void addmod(int &a, long long b) {
a = (a + b);
if (a >= 1000000007) a -= 1000000007;
}
void mulmod(int &a, long long b) { a = (a * b) % 1000000007; }
template <class T>
bool domin(T &a, const T &b) {
return a > b ? a = b, 1 : 0;
}
template <class T>
bool domax(T &a, ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const long double EPS = 1e-9;
const int MOD = 1000000007;
const long long LLINF = 1000000000000000001;
const int maxn = 400000;
const int maxb = 40;
long long dp[maxn][maxb];
long long v[maxn];
int n;
int main() {
cin >> n;
for (int i = 1; i ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dp[300100][42];
int a[300100], n;
void make(int &x, int y) {
if (x == -1)
x = y;
else
x = min(x, y);
}
int main() {
memset(dp, -1, sizeof(dp));
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
dp[0][0] = 0;
for (int i = 0; i < n; +... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, inf = 1e9 + 7;
int a[N], dp[2][50], now, n;
void gmin(int &a, int b) {
if (a > b) a = b;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", a + i), a[i] /= 100;
now = 0;
for (int i = 1; i <= 40; ++i) dp[now][i] = inf;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
int a[300005];
int dp[300005][35];
int solve(int idx, int cur) {
if (idx == n) return 0;
int &ret = dp[idx][cur];
if (~ret) return ret;
int x = min(a[idx], cur);
ret = solve(idx + 1, cur - x) + a[idx] - x;
if (a[idx] / 10 + cur <= 30)
ret = min(ret, a... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
const int L = 40;
const int oo = 1e9;
int N, A[maxn];
int dp[L + 5][maxn];
inline void change(int &ret, int v) {
if (ret > v) ret = v;
}
int solve() {
for (int i = (0), _i = (L + 1); i <= _i; i++)
for (int j = (0), _j = (N); j <= _j; j++)... | 10 | CPP |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T>
using vec = std::vector<T>;
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
struct Input {
Input(istream &in) : in(&in) {... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int B = 50;
const int oo = 1e9;
int dp[N][B];
int n, a[N];
int f(int i, int j) {
if (i == n) return 0;
if (j >= B) return oo;
int &ans = dp[i][j];
if (~ans) return ans;
ans = f(i + 1, j + a[i]) + a[i] * 10;
int nj = j - a[i] * 10;
i... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int KN = 3e5 + 5, KInfL = 0x3f3f3f3f;
int n, m = 30, c[KN], f[KN][31];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> c[i];
memset(f, 0x3f, sizeof f);
f[0][0] = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 0; ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxN = 300000 + 13;
int a[maxN], N;
long long f[maxN][40];
int main() {
scanf("%d", &N);
for (int i = (1), _ed = (N + 1); i < _ed; i++) scanf("%d", &a[i]);
memset(f, 0x3f, sizeof(f));
f[0][0] = 0;
for (int i = (1), _ed = (N + 1); i < _ed; i++) {
int ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n, count1 = 0, count2 = 0;
int test(int a, int b) {
int x = count1, y = count2;
int ans = 0, bon = 0;
for (int i = 0; i < n; i++) {
if (v[i] == 1000) {
if (x > a)
ans += 10, bon += 1, x--;
else {
int aux = min(10, bon... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int a[300010], n;
int res[300010][110];
int dp(int id, int cs) {
if (id == n) return 0;
if (res[id][cs] != -1) return res[id][cs];
int tk = min(cs * 100, a[id]);
int w = a[id] - tk + dp(id + 1, cs - tk / 100);
if (cs < 100) w = min(w, a[id] + dp(id + 1, cs + a[id]... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] /= 100;
}
vector<vector<int> > dp(n + 1, vector<int>(100, 1000000000));
dp[0][0] = 0;
for (int i = 0... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, a[300300], flag[300300];
int solveSkip(int budget) {
int bonus = 0;
for (int i = 0; i < n; i++) {
if (flag[i]) {
if (budget < a[i]) return 0;
budget -= a[i];
bonus += a[i] / 10;
} else if (bonus >= a[i])
bonus -= a[i];
else if ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double inf = 1e15;
long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
ret... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAXD = 40;
int n, a[300005];
long long f[300005][MAXD + 5];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i <= n; ++i) a[i] /= 100;
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= MAXD; ++j) f[i][j] = ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int a[300005], f[300005][35], n, ans;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] /= 100;
memset(f, 60, sizeof(f));
f[0][0] = 0;
for (int i = 1; i <= n; i++)
for (int j = 0; j <= 31; j++) {
if (j + a[i] / 10 <= 31)... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
int a[300010], s[300010];
int f1[300010];
int next1[300010], next2[300010];
int ans = 0;
int getS(int l, int r) { return s[r] - s[l - 1]; }
void pre_gao() {
int last1 = n + 1, last2 = n + 1;
for (int i = n; i >= 1; i--) {
next1[i] = last1;
next2[i] = last... | 10 | CPP |
#include <bits/stdc++.h>
const double PI = acos(-1);
const int MAXX = 10005;
const int maxInt = 2147483647;
using namespace std;
int a[300010], n;
inline int read() {
int k = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, A[300010];
int dp[300010][35];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &A[i]);
A[i] /= 100;
}
for (int i = 0; i <= n; i++)
for (int j = 0; j < 35; j++) dp[i][j] = 2147482647;
dp[0][0] = 0;
for (int i = 1; i <= ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAXD = 100;
int n, a[300005];
long long f[300005][MAXD + 5];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i <= n; ++i) a[i] /= 100;
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= MAXD; ++j) f[i][j] =... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 29;
int main() {
int n, dpa[300], dpb[300], t, ans = MAX;
scanf("%d", &n);
dpa[0] = 0;
for (int i = 1; i < 300; i++) dpa[i] = MAX;
while (n--) {
scanf("%d", &t);
for (int i = 0; i < 300; i++) dpb[i] = MAX;
if (t == 1000) {
fo... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dp[305000][41];
int a[305000], n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
a[i] /= 100;
}
memset(dp, 0x3f3f3f3f, sizeof(dp));
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 30; j++) {
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long dp[300005][35], n;
int ara[600005];
long long dp_func(int pos, int ase) {
if (pos > n) return 0;
if (dp[pos][ase] != -1) return dp[pos][ase];
long long ret = 21474836499999;
ret = min(ret, dp_func(pos + 1, max(ase - ara[pos] / 100, 0)) +
... | 10 | CPP |
#include <bits/stdc++.h>
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
while (*sdbg != ',') cerr << *sdbg++;
c... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long n;
cin >> n;
int a[n];
long long b[n];
memset(b, 0, sizeof(b));
int t1 = 0;
for (long i = 0; i < n; i++) {
cin >> a[i];
a[i] = a[i] / 1000;
if (a[i] == 1) t1 = 1;
if (i == 0)
b[0] = a[0];
else
b[i] = b[i - 1] +... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, a[N], sum[N], cnt[N];
int lf[N], rt[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = (1); i <= (n); ++i) cin >> a[i], a[i] /= 1000;
for (int i = (1); i <= (n); ++i)
sum[i] = sum[i - 1] + a[i], c... | 10 | CPP |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <typename T>
inline T abs(T a) {
return ((a < 0) ? -a : a);
}
template <typename T>
inline T sqr(T a) {
return a * a;
}
template <class T>
T gcd(T a, T b) {
return a ? gcd(b % a, a) : b;
}
template <class T>
T lcm(T... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
int data[N];
int main() {
int n;
scanf("%d", &n);
int cc = 0, sum = 0;
for (int i = (1); i < (n + 1); ++i) {
scanf("%d", &data[i]);
sum += data[i] / 1000;
if (data[i] == 1000) cc++;
}
int tmp = 10 * sum / 11;
if (sum <= 11) t... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int a = 0, po = 1;
char ch = getchar();
while (!isdigit(ch) && ch != '-') ch = getchar();
if (ch == '-') po = -1, ch = getchar();
while (isdigit(ch)) a = a * 10 + ch - '0', ch = getchar();
return a * po;
}
int n;
int x[300010];
int tot, ans, ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void desperate_optimization(int precision) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(precision);
}
const int N = 3e5;
const int M = 32;
const int MAXN = 2e9;
int dp[M + 5][N + 5]... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1123456;
int x[MAX];
int n;
int solve(int a, int b) {
int k = 0, j = 0;
for (int i = 1; i <= n; i++) {
if (x[i] == 1000)
a--;
else
b--;
if (x[i] == 1000 && a >= 0 || x[i] == 2000 && b >= 0) {
k += x[i], j += x[i] / 10;
}... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;
const long long linf = 1ll * inf * inf;
const int N = 300000 + 7;
const int M = 62;
const int multipleTest = 0;
int dp[N][M];
int n;
int a[N];
void solve() {
cin >> n;
for (int i = (0), _b = (N); i < _b; ++i)
for (int j = (0), _b = (M); j... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m, ans, two, one, l, r, k, a[N], dp[N][205];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &k);
a[i] = k / 100;
if (a[i] == 20)
two++;
else
one++;
}
memset(dp, 127, sizeof(dp));
dp... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n, t, s, coun, a[300010];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
s += a[i] / 1000;
if (a[i] == 1000) {
coun++;
}
}
t = s * 10 / 11;
if (s <= 11) {
t = s - a[n] / 1000;
}
if (coun == 0 && (t & 1))... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = .3e6 + 5;
const int X = 600 + 5;
int n;
int A[N], C[N];
int dp[2][X];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i];
A[i] /= 100;
C[i] = A[i] / 10;
}
for (int i = n; i >= 1; i--) ... | 10 | CPP |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667177216")
using namespace std;
const long long MOD = 1000000000 + 7;
long long D[3 * 100000 + 5][45];
long long rec(vector<int> &a, int pos, int have) {
if (pos == a.size()) return 0;
if (D[pos][have] != -1) return D[pos][have];
long long mini = 999999999... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod = 1000000007;
const double pi = acos(-1.0);
inline void gn(long long& x) {
int sg = 1;
char c;
while (((c = getchar()) < '0' || c > '9') && c != '-')
;
c == '-' ? (sg = -1, x = 0) : (x = c - '0')... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 300300;
const int INF = 2 * N;
int a[N];
bool b[N];
int n;
bool evaluate(int x) {
int bal = 0;
for (int i = 0; i < n; i++) {
if (b[i]) {
int val = min(bal, a[i]);
bal -= val;
x -= val;
} else {
bal += a[i] / 10;
}
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1123456;
int x[MAX];
int n;
int solve(int a, int b) {
int k = 0, j = 0;
for (int i = 1; i <= n; i++) {
if (x[i] == 1000)
a--;
else
b--;
if (x[i] == 1000 && a >= 0 || x[i] == 2000 && b >= 0) {
k += x[i], j += x[i] / 10;
}... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int Total;
int Array[400001];
int Sum, Count;
int main(void) {
register int i;
cin >> Total;
for (i = 1; i <= Total; i++) {
cin >> Array[i];
Sum += Array[i] / 1000;
Count += (Array[i] == 1000);
}
register int Tmp;
Tmp = Sum * 10 / 11;
if (Sum <= 11... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int const N = 3e5 + 10;
int dp[2][40];
int cost[N];
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &cost[i]);
cost[i] /= 100;
}
int now = 0;
for (int _ = 0; _ <= 30; _++) dp[now][_] = 0x3f3f3f3f;
dp[now][0] = 0;
for (in... | 10 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.