QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784187#3565. Beer PressureSGColin#100 ✓68ms3756kbC++201.4kb2024-11-26 13:58:312024-11-26 13:58:32

Judging History

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

  • [2024-11-26 13:58:32]
  • 评测
  • 测评结果:100
  • 用时:68ms
  • 内存:3756kb
  • [2024-11-26 13:58:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

int n, k, base, num[6];

double ans[6];

void dfs(int pos, int rem, int vote, double p) {
    //printf("%d %d %d %.2lf\n", pos, rem, vote, p); fflush(stdout);
    if (pos > n) {
        if (rem) return;
        vector<int> winner;
        winner.eb(1);
        rep(i, 2, n) {
            if (num[i] > num[winner[0]]) {
                winner.clear();
                winner.eb(i);
            } else if (num[i] == num[winner[0]]) winner.eb(i);
        }
        for (auto x : winner) ans[x] += p / winner.size();
        return;
    }
    int ori = num[pos];
    rep(i, 0, rem) {
        dfs(pos + 1, rem - i, vote, p);
        p = p * num[pos] / (i + 1) * (vote - base + 1) / vote;
        ++num[pos]; ++vote;
    }
    num[pos] = ori;
}

inline void work() {
    vector<int> s;
    base = 0;
    rep(i, 1, n) {
        ans[i] = 0;
        cin >> num[i];
        k -= num[i];
        base += num[i];
    }
    dfs(1, k, base, 1.0);
    rep(i, 1, n) printf("pub %d: %.2lf \%\n", i, ans[i] * 100);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> n >> k) work();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 100
Accepted
time: 68ms
memory: 3756kb

input:

3 7
3 1 1
1 1
1
1 50
1
2 2
1 1
2 50
1 1
2 50
1 2
3 3
1 1 1
3 50
1 1 1
3 50
1 1 2
4 4
1 1 1 1
4 50
1 1 1 1
4 50
1 1 1 2
5 5
1 1 1 1 1
5 50
1 1 1 1 1
5 50
1 1 1 1 2
4 49
2 10 4 2
4 36
4 3 2 4
3 27
2 6 10
1 16
9
3 43
3 6 3
2 28
6 5
3 37
5 7 9
1 44
1
5 44
8 1 9 8 7
3 46
8 2 6
4 28
4 10 4 9
4 50
1 8 6 4
...

output:

pub 1: 93.33 %
pub 2: 3.33 %
pub 3: 3.33 %
pub 1: 100.00 %
pub 1: 100.00 %
pub 1: 50.00 %
pub 2: 50.00 %
pub 1: 50.00 %
pub 2: 50.00 %
pub 1: 24.49 %
pub 2: 75.51 %
pub 1: 33.33 %
pub 2: 33.33 %
pub 3: 33.33 %
pub 1: 33.33 %
pub 2: 33.33 %
pub 3: 33.33 %
pub 1: 19.01 %
pub 2: 19.01 %
pub 3: 61.98 %
...

result:

ok 356 lines