QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268394#7041. Girls Band Party8BQube#AC ✓331ms10616kbC++202.9kb2023-11-28 16:57:312023-11-28 16:57:31

Judging History

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

  • [2023-11-28 16:57:31]
  • 评测
  • 测评结果:AC
  • 用时:331ms
  • 内存:10616kb
  • [2023-11-28 16:57:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define SZ(a) ((int)a.size())

struct Info {
    string name, color;
    int power;
} info[100005];

void solve() {
    vector<int> pw[6][2];
    map<string, pii> other;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> info[i].name >> info[i].color >> info[i].power;
    }
    vector<string> bname;
    string bcolor;
    for (int i = 0; i < 5; ++i) {
        string s;
        cin >> s;
        bname.pb(s);
    }
    cin >> bcolor;
    for (int i = 1; i <= n; ++i) {
        int idx = find(ALL(bname), info[i].name) - bname.begin(); 
        int mch = int(info[i].color == bcolor);
        if (idx == 5) {
            auto p = other.find(info[i].name);
            pii res;
            if (p != other.end()) res = p->Y;
            else res = pii(0, 0);
            if (mch) res.Y = max(res.Y, info[i].power);
            else res.X = max(res.X, info[i].power);
            other[info[i].name] = res;
        }
        else pw[idx][mch].pb(info[i].power);
    }
    for (int i = 0; i < 5; ++i)
        for (int j = 0; j < 2; ++j)
            sort(ALL(pw[i][j]), greater<>());
    int dp[6][6] = {};
    for (auto &[s, v] : other) {
        for (int i = 5; i >= 1; --i)
            for (int j = 0; j <= 5; ++j) {
                if (v.X && dp[i - 1][j]) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j] + v.X);
                }
                if (v.Y && j && dp[i - 1][j - 1]) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + v.Y);
                }
            }
        if (v.X) dp[1][0] = max(dp[1][0], v.X);
        if (v.Y) dp[1][1] = max(dp[1][1], v.Y);
    }

    auto cal = [&](int i, int j) {
        int pt = 0, sum = 0, bonus = 100, rmd = 5, cnt = __builtin_popcount(j);
        for (int k = 0; k < 5; ++k)
            if (i >> k & 1) {
                int mch = (j >> pt) & 1;
                if (SZ(pw[k][mch]) <= 0) return pii(0, 0);
                sum += pw[k][mch][0];
                bonus += 10 + 20 * mch;
                ++pt, cnt -= mch, --rmd; 
            }
        //cerr << i << " " << j << " " << rmd << " " << cnt << "!!\n";
        if (rmd + cnt && !dp[rmd][cnt]) return pii(0, 0);
        bonus += 20 * cnt;
        sum += dp[rmd][cnt];
        //cerr << i << " " << j << " " << rmd << " " << cnt << " " << sum << " " << bonus << " " << sum * bonus / 100 << "\n";
        return pii(sum, bonus);
    };

    int ans = 0;
    for (int i = 0; i < (1 << 5); ++i)
        for (int j = 0; j < (1 << 5); ++j) {
            auto [sum, bonus] = cal(i, j);
            ans = max(ans, sum * bonus / 100);
        }
    cout << ans << "\n";
}

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

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 10520kb

input:

1
6
Saaya Power 45000
Kokoro Happy 45000
Kasumi Cool 45000
Rimi Power 45000
Aya Pure 45000
Aya Power 2000
Saaya Tae Kasumi Rimi Arisa
Power

output:

382500

result:

ok 1 number(s): "382500"

Test #2:

score: 0
Accepted
time: 331ms
memory: 10584kb

input:

50
6
Tae Pure 13573
Chisato Happy 48889
Hina Power 36087
Kasumi Cool 5878
Rimi Power 21091
Rinko Cool 21035
Eve Tomoe Sayo Saya Tsugumi
Power
8
Hina Power 33669
Kokoro Happy 48080
Tsugumi Cool 37215
Lisa Power 22671
Kaoru Pure 3556
Hagumi Happy 26536
Rimi Power 20561
Maya Power 29893
Kaoru Chisato H...

output:

196945
265697
185972
181747
190528
187408
110113
238308
223522
233073
561365
531401
474005
604145
393206
497631
598267
535132
404644
501993
623480
525683
623575
624482
624315
624057
624042
536709
624202
623755
622960
622482
624082
623832
623182
622470
618160
623535
624680
622372
624385
623042
622857...

result:

ok 50 numbers

Test #3:

score: 0
Accepted
time: 275ms
memory: 10616kb

input:

50
6
Rinko Cool 29445
Sayo Power 33447
Rimi Power 47202
Rinko Power 13982
Himari Power 2156
Moca Cool 45728
Kaoru Moca Hagumi Aya Kanon
Happy
10
Misaki Pure 11868
Maya Pure 46263
Aya Power 36991
Tsugumi Happy 27068
Tomoe Pure 41757
Aya Cool 44328
Saaya Happy 46221
Arisa Cool 31545
Kanon Happy 25467
...

output:

173775
321889
151163
255470
234021
199576
223339
262045
193091
225840
169657
191240
192443
222483
96308
184369
341478
181268
166455
258093
620735
610022
617712
623135
622237
623880
614360
622132
623332
623607
620665
618695
623477
619787
621477
623012
618887
616462
623855
622627
623852
624200
624540
...

result:

ok 50 numbers