QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#272189 | #7793. 雷同 | Froranzen | 5 | 11ms | 33288kb | C++23 | 2.5kb | 2023-12-02 16:23:53 | 2023-12-02 16:23:55 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, f, t) for(int i(f); i <= t; ++i)
#define re(i, t) for(int i(1); i <= t; ++i)
#define per(i, t, f) for(int i(t); i >= f; --i)
#define pe(i, t) for(int i(t); i >= 1; --i)
#define nx(i, u) for(int i(head[u]); i; i = e[i].nxt)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
// #define int long long
using namespace std;
typedef pair <int, int> pii;
#define pb push_back
#define fi first
#define se second
#define ix(l, r) ((l + r) | (l != r))
#define ls (ix(l, mid))
#define rs (ix(mid + 1, r))
#define mp(i, j) (make_pair(i, j))
#define inf (int)(1e9+7)
#define INF 0x3f3f3f3f3f3f3f3f
#define eps 1e-10
#define look_memory cerr<<abs(&sT-&eD)/1024.0/1024<<'\n'
bool sT;
namespace IO {
char buf[1 << 21], *p1 = buf, *p2 = buf, buf1[1 << 21];
inline char gc() {
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++;
}
#ifndef ONLINE_JUDGE
#endif
// #define gc getchar
template<class I>
inline void read(I &x) {
x = 0;
I f = 1;
char c = gc();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = gc();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = gc();
}
x *= f;
}
template<class I>
inline void write(I x) {
if (x == 0) {
putchar('0');
return;
}
I tmp = x > 0 ? x : -x;
if (x < 0)
putchar('-');
int cnt = 0;
while (tmp > 0) {
buf1[cnt++] = tmp % 10 + '0';
tmp /= 10;
}
while (cnt > 0)
putchar(buf1[--cnt]);
}
#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')
} using namespace IO;
const int N = 1e4 + 5;
int T, n;
int a[N];
ll f[N*N/2];
ll pre[N];
int num[N];
#define lowbit(x) (x & (-x))
int id (int a, int b) {
return num[a] + b + 1;
}
int main () {
read(T);
while(T--) {
read(n);
re(i, n) read(a[i]);
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
re(i, n) pre[i] = pre[i-1] + a[i];
num[1] = n+1;
rep(i, 2, n) {
num[i] = num[i-1] + (n-i+2);
}
rep(i, 0, n) {
rep(j, 0, n) f[id(i,j)] = INF;
}
f[id(0, 1)] = 0;
rep(i, 0, n) {
if(i) {
rep(j, 0, n-i) {
f[id(i, j)] = min(f[id(i, j)], f[id(i-1, j+1)] + (lowbit(j) >> 1));
}
}
re(j, n-i) {
if(j % 2 == 0) f[id(i, j)] = min(f[id(i, j)], f[id(i, j>>1)] + pre[n] - pre[i]);
}
}
outn(f[id(n, 0)]);
}
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 7512kb
input:
4 6 1 3 5 7 9 11 6 2 4 6 8 10 12 6 100 1000 100 10 100 10 2 114514 1919810
output:
86 103 1981 2034324
result:
ok 4 tokens
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 7512kb
input:
5 12 2 4 3 2 2 3 4 2 3 2 2 1 12 3 3 3 2 3 2 3 2 1 1 2 4 12 6 2 2 2 5 4 6 1 2 8 8 6 12 1 4 2 2 1 6 7 2 4 1 7 5 12 11 1 2 6 16 16 15 8 8 16 6 12
output:
112 108 182 145 399
result:
wrong answer 1st words differ - expected: '114', found: '112'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Wrong Answer
Test #39:
score: 0
Wrong Answer
time: 11ms
memory: 33288kb
input:
2 2500 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...
output:
91483 37354248711
result:
wrong answer 1st words differ - expected: '96493', found: '91483'
Subtask #7:
score: 0
Skipped
Dependency #5:
0%