QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#778164#5137. TowerBicycle_23#WA 28ms3572kbC++231.1kb2024-11-24 13:03:362024-11-24 13:03:38

Judging History

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

  • [2024-11-24 13:03:38]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3572kb
  • [2024-11-24 13:03:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

constexpr int maxn = 2e5 + 5;
int n, m;
vector<int> a;

void solve()
{
    cin >> n >> m;
    a = vector<int>(n + 1, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<int> dp(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        priority_queue<int> q;
        int h = a[i];
        for (int j = 1; j <= n; j++)
        {
            // cout << " ? " << endl;
            if (i == j) {q.push(0); continue;}
            int x = a[j];
            int ans = 0;
            if (x <= h) {ans = h - x;}
            else
            {
                while (x >= 2 * h) {ans++; x /= 2;}
                ans += min(x - h, 1 + h - (x / 2));
            }
            q.push(ans);
        }
        for (int j = 1; j <= m; j++) q.pop();
        while (!q.empty()) {dp[i] += q.top(); q.pop();}
    }
    int ans = *min_element(dp.begin() + 1, dp.end());
    cout << ans << endl;
}

signed main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);
    int _ = 1;
    cin >> _;
    while (_--) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

3
2 0
2 6
5 0
1 2 3 4 5
5 3
1 2 3 4 5

output:

2
4
1

result:

ok 3 number(s): "2 4 1"

Test #2:

score: 0
Accepted
time: 28ms
memory: 3568kb

input:

10
272 118
11 14 49 94 71 62 46 45 74 22 15 36 7 37 27 35 96 85 75 78 76 64 23 59 17 35 71 28 96 82 5 66 2 48 57 31 88 10 61 73 79 23 19 52 39 76 48 98 5 39 48 51 90 90 60 27 47 24 24 56 48 27 39 21 38 18 20 9 62 83 47 15 51 22 73 74 7 80 64 60 86 74 59 7 84 38 99 31 42 60 52 41 63 88 59 90 77 40 68...

output:

454
3
436
108
570
636
994
227
656
50

result:

ok 10 numbers

Test #3:

score: -100
Wrong Answer
time: 26ms
memory: 3572kb

input:

10
133 89
20 70 6 45 4 72 38 7 18 1 82 39 69 85 5 36 1 62 30 47 68 55 7 41 7 42 7 61 11 82 2 80 80 93 29 30 42 58 73 26 99 67 60 94 61 46 47 54 44 50 35 88 61 17 23 97 90 28 16 47 75 35 28 14 42 63 26 40 95 58 26 25 26 83 93 56 17 27 7 90 91 28 53 49 47 84 55 52 11 34 14 74 40 65 84 32 99 46 1 21 31...

output:

88
1361
128
246
29
83
3
677
97
382

result:

wrong answer 9th numbers differ - expected: '96', found: '97'