QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#355374#7793. 雷同moonstaring5 12ms3668kbC++141.0kb2024-03-16 16:38:082024-03-16 16:38:09

Judging History

你现在查看的是最新测评结果

  • [2024-03-16 16:38:09]
  • 评测
  • 测评结果:5
  • 用时:12ms
  • 内存:3668kb
  • [2024-03-16 16:38:08]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i,j,k) for(int i = (j); i <= (k); ++i)
#define R(i,j,k) for(int i = (j); i >= (k); --i)
#define ll long long
#define pb push_back
#define mk make_pair
#define sz(a) (int)(a).size()
using namespace std;
const int N = 1e4 + 4;
ll w[N];
int n;
ll f[N], g[N];
int lb(int wi){
    return wi & -wi;
}
void solve(){
    cin >> n;
    L(i, 1, n) cin >> w[i];
    sort(w + 1, w + n + 1);
    L(i, 1, n) w[i] += w[i - 1];
    g[0] = 0; 
    L(i, 1, n) g[i] = 1e18;
    L(i, 0, n){
        L(j, 0, n) f[j] = g[j], g[j] = 1e18;
        R(j, i, 0){
            if(j % 2 == 0 && j > 0){
                f[j / 2] = min(f[j / 2] ,f[j] + w[i]);
            }
            g[j + 1] = min(g[j + 1], f[j] + (lb(j) >> 1));
        }
        // L(j, 1, i)
        //     cout << f[j] << " ";
        // cout <<"\n";
    } 
    cout << f[1] <<"\n";
}
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 3668kb

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: 0ms
memory: 3596kb

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: 12ms
memory: 3664kb

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%