QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#180427 | #7084. Fighting Against Monsters | brz# | WA | 602ms | 37976kb | C++20 | 3.4kb | 2023-09-15 20:23:14 | 2023-09-15 20:23:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fo(i,j,k) for(int i=(j),end_i=(k);i<=end_i;i++)
#define ff(i,j,k) for(int i=(j),end_i=(k);i< end_i;i++)
#define fd(i,j,k) for(int i=(j),end_i=(k);i>=end_i;i--)
#define debug(x) cerr<<#x<<"="<<x<<endl
#define debugv(x) cerr<<#x<<" : "; ff(i,0,(x).size()) cerr<<(x)[i]<<(i==(x).size()-1?'\n':' ')
#define all(x) (x).begin(),(x).end()
#define cle(x) memset(x,0,sizeof(x))
#define lowbit(x) ((x)&-(x))
#define VI vector<int>
#define ll long long
#define ull unsigned ll
#define lll __int128
#define db double
#define lb long db
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
template<class T>inline void read(T &x) {
x=0; char ch=getchar(); bool f=0;
for(;ch<'0'||ch>'9';ch=getchar()) f|=(ch=='-');
for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+(ch^48);
if(f) x=-x;
}
template<class T, class... V>
inline void read(T &a, V&... b){read(a); read(b...);}
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
int A,B;
ll ha,hb,hc,C;
const int N = 103;
bool vis[N * N];
ll g[N * N];
inline ll ask(ll k, ll i) {
k *= 2;
ll l = 0, r = 2e9, mid;
for (;l + 1 < r;) {
mid = (l + r) >> 1;
if (mid * (mid + i + i - 1) >= k)
r = mid;
else
l = mid;
}
return r;
}
inline ll ask2(int k, int i) {
if (k >= C)
return 0;
return ask(C-k, i);
}
namespace Sub1 {
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll f[N][N<<1][N<<1];
inline void getmin(ll &a, ll b) {
a = min(a, b);
}
inline ll solve() {
ll ans = inf;
memset(f,0x3f,sizeof(f));
f[0][0][0] = 0;
fo(i,1,101)
fo(j,0,A + 100)
fo(k,0,B + 100)
if (f[i-1][j][k] < inf) {
if (j >= A && k >= B) {
//debug(i-1); debug(j); debug(k); debug(f[i-1][j][k]);
ans = min(ans, f[i-1][j][k] + ask2(i*(i-1)/2-j-k, i) * hc);
continue;
}
if (i == 101)
continue;
getmin(f[i][min(A + 100, j + i)][k], f[i-1][j][k] + (j >= A ? 0 : ha) + (k >= B ? 0 : hb) + ((i*(i-1)/2-j-k) >= C ? 0 : hc));
getmin(f[i][j][min(B + 100, k + i)], f[i-1][j][k] + (j >= A ? 0 : ha) + (k >= B ? 0 : hb) + ((i*(i-1)/2-j-k) >= C ? 0 : hc));
getmin(f[i][j][k], f[i-1][j][k] + (j >= A ? 0 : ha) + (k >= B ? 0 : hb) + ((i*(i-1)/2-j-k) >= C ? 0 : hc));
}
return ans;
}
}
inline ll ask(ll k) {
k *= 2;
ll l = 0, r = 2e9, mid;
for (;l + 1 < r;) {
mid = (l + r) >> 1;
if (mid * (mid + 1) >= k)
r = mid;
else
l = mid;
}
return r;
}
void Solve() {
read(A,B,C,ha,hb,hc);
ll ans = Sub1::solve();
if (C > 5000) {
ll tc = ask(C);
ans = min(ans, tc * (ha + hb + hc) + ha + hb + min(ha, hb));
ans = min({ans, ask(A) * ha + ask(A + C) * (hb + hc) + hb, ask(B) * hb + ask(B + C) * (ha + hc) + ha});
}
printf("%lld\n", ans);
}
int main() {
//ios::sync_with_stdio(0); cin.tie(0);
int T = 1;
read(T);
for(;T--;) Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 37880kb
input:
2 1 10 100 3 2 1 3 2 1 1 10 100
output:
28 123
result:
ok 2 tokens
Test #2:
score: -100
Wrong Answer
time: 602ms
memory: 37976kb
input:
20 100 100 4465 1 1 1000000000 100 100 4560 1 1 1000000000 100 100 4656 1 1 1000000000 100 100 4753 1 1 1000000000 100 100 4851 1 1 1000000000 100 100 4950 1 1 1000000000 100 100 5050 1 1 1000000000 100 100 5151 1 1 1000000000 100 100 5253 1 1 1000000000 100 100 4372 1 1 1000000000 100 100 4466 1 1 ...
output:
94000000194 95000000196 96000000198 97000000199 101000000034 101000000035 100000000203 101000000205 102000000207 94000000191 95000000193 96000000195 97000000197 98000000199 101000000034 101000000035 101000000116 102000000117 103000000118 1414213596000000000
result:
wrong answer 5th words differ - expected: '98000000201', found: '101000000034'