QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#615509 | #2544. Flatland Currency | cyj888 | WA | 499ms | 8516kb | C++11 | 1.5kb | 2024-10-05 19:07:55 | 2024-10-05 19:07:58 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define ott(i, l, r) for (int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (int i = (r); i >= (l); i --)
int read () {
int x = 0; bool f = 0; char c = getchar ();
while (!isdigit (c)) f |= (c == '-'), c = getchar ();
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
if (f) x = -x; return x;
}
using namespace std;
using ll = long long;
const int N = 1e5 + 110, mod = 1e9 + 7, inf = 0x3f3f3f3f;
int n, m, rs, sum, res, now; ll x;
ll f[N << 2];
struct Bag {
ll v; int w;
} a[N];
int main () {
n = read (), scanf ("%lld", &x);
rs = x % 5, x = (x - rs) / 5ll;
ott (i, 1, n) {
ll y; scanf ("%lld", &y);
a[i].w = y % 5, a[i].v = (y - a[i].w) / 5ll;
if (a[i].w) a[i].w = 5 - a[i].w, ++ a[i].v;
m += a[i].w;
}
memset (f, 0x3f, sizeof f); f[0] = 0;
if (n <= 3000)
ott (i, 1, n)
tto (j, a[i].w, m)
f[j] = min (f[j], f[j - a[i].w] + a[i].v);
else {
m = 0;
ott (i, 1, n) {
m += a[i].w;
tto (j, max (a[i].w, m - 2000), m) f[j] = min (f[j], f[j - a[i].w] + a[i].v);
tto (j, max (a[i].w, m / 2 - 2000), m / 2) f[j] = min (f[j], f[j - a[i].w] + a[i].v);
tto (j, max (a[i].w, 24000), min (m, 26000)) f[j] = min (f[j], f[j - a[i].w] + a[i].v);
tto (j, max (a[i].w, 122000), min (m, 126000)) f[j] = min (f[j], f[j - a[i].w] + a[i].v);
}
}
ott (j, 0, m)
if (f[j] <= x)
res = max (res, j);
printf ("%d\n", sum + res + rs);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8364kb
input:
5 57 9 14 31 18 27
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 7212kb
input:
4 50 11 11 11 11
output:
12
result:
ok answer is '12'
Test #3:
score: 0
Accepted
time: 499ms
memory: 8516kb
input:
100000 89648823509660 921733427 402270498 51157221 585477094 435728758 913951087 580580944 557082810 585086423 837912728 799129405 867009344 751591136 714946046 464999915 256043168 416678301 183246216 569365122 479031618 435168577 31068363 903791719 497652990 960987871 223120213 395437892 112869678 ...
output:
200414
result:
ok answer is '200414'
Test #4:
score: -100
Wrong Answer
time: 499ms
memory: 8464kb
input:
99999 3234700062922 394766137 401419056 55997758 205712163 585962152 750591556 245421581 607883471 437707305 758188075 522354844 202404802 307099733 99935245 321784033 643800024 481548024 43007287 404431495 848761213 352455926 541535791 702868758 875691279 485597478 119612707 776231855 48839061 1144...
output:
42017
result:
wrong answer expected '61505', found '42017'