QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863167#9749. 小凯的省奖之梦DukerkiWA 285ms3584kbC++205.1kb2025-01-19 14:00:062025-01-19 14:00:06

Judging History

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

  • [2025-01-19 14:00:06]
  • 评测
  • 测评结果:WA
  • 用时:285ms
  • 内存:3584kb
  • [2025-01-19 14:00:06]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n, m;
int ori[2];
struct student {
    string name;
    int score1[3], score2[3];
    int sum1, sum2, sum3;//第一学期综测,第二学期综测,总综测
    int totalstudy;//总智育
    //需要置零
    int studyrank;//智育排名
    int bonussum;
}stu[505];
bool check() {
    int firstbonus = n * 0.15, secondbonus = n * 0.25, thirdbonus = n * 0.35;
    int firstrank = n * 0.25, secondrank = n * 0.45, thirdrank = n * 0.75;
    //计算第一学期综测排名
    //先计算智育排名
    sort(stu, stu + n, [](student& a, student& b) {
        return a.score1[0] > b.score1[0];
        });
    int cnt = 1;
    for (int i = 0; i < n; i++)
    {
        stu[i].studyrank = cnt;
        if (stu[i].score1[0] != stu[i + 1].score1[0]) {
            cnt++;
        }
    }
    //根据综测排名计算奖学金
    sort(stu, stu + n, [](student& a, student& b) {
        if (a.sum1 == b.sum1) {
            return a.name < b.name;
        }
        return a.sum1 > b.sum1;
        });
    for (int i = 0; i < n; i++)
    {
        if (firstbonus > 0 && stu[i].studyrank <= firstrank) {
            stu[i].bonussum += 15;
            firstbonus--;
            continue;
        }
        else if (secondbonus > 0 && stu[i].studyrank <= secondrank) {
            stu[i].bonussum += 10;
            secondbonus--;
            continue;
        }
        else if (thirdbonus > 0 && stu[i].studyrank <= thirdrank) {
            stu[i].bonussum += 5;
            thirdbonus--;
            continue;
        }
    }
    //计算第二学期
    firstbonus = n * 0.15, secondbonus = n * 0.25, thirdbonus = n * 0.35;
    //先计算智育排名
    sort(stu, stu + n, [](student& a, student& b) {
        return a.score2[0] > b.score2[0];
    });
    cnt = 1;
    for (int i = 0; i < n; i++)
    {
        stu[i].studyrank = cnt;
        if (stu[i].score2[0] != stu[i + 1].score2[0]) {
            cnt++;
        }
    }
    //根据综测排名计算奖学金
    sort(stu, stu + n, [](student& a, student& b) {
        if (a.sum2 == b.sum2) {
            return a.name < b.name;
        }
        return a.sum2 > b.sum2;
    });
    for (int i = 0; i < n; i++)
    {
        if (firstbonus > 0 && stu[i].studyrank <= firstrank) {
            stu[i].bonussum += 15;
            firstbonus--;
            continue;
        }
        else if (secondbonus > 0 && stu[i].studyrank <= secondrank) {
            stu[i].bonussum += 10;
            secondbonus--;
            continue;
        }
        else if (thirdbonus > 0 && stu[i].studyrank <= thirdrank) {
            stu[i].bonussum += 5;
            thirdbonus--;
            continue;
        }
    }
    //计算最终排名
    sort(stu, stu + n, [](student& a, student& b) {
        if (a.bonussum == b.bonussum) {
            if (a.sum3 == b.sum3) {
                if (a.totalstudy == b.totalstudy) {
                    return a.name < b.name;
                }
                return a.totalstudy > b.totalstudy;
            }
            return a.sum3 > b.sum3;
        }
        return a.bonussum > b.bonussum;
    });
    for (int i = 0; i < n; i++)
    {
        if (stu[i].name == "crazyzhk") {
            return (i + 1) <= m;
        }
    }
    //return false;
}
void init(int p, int q) {
    for (int i = 0; i < n; i++)
    {
        stu[i].bonussum = 0;
        stu[i].studyrank = 0;
        if (stu[i].name == "crazyzhk") {
            stu[i].score1[0] = ori[0] + p;
            stu[i].score2[0] = ori[1] + q;
            stu[i].sum1 = stu[i].score1[0] + stu[i].score1[1] + stu[i].score1[2];
            stu[i].sum2 = stu[i].score2[0] + stu[i].score2[1] + stu[i].score2[2];
            stu[i].sum3 = stu[i].sum1 + stu[i].sum2;
            stu[i].totalstudy = stu[i].score1[0] + stu[i].score2[0];
        }
    }

}
int main() {
    cin >> n;
    int p, q;
    for (int i = 0; i < n; i++)
    {
        cin >> stu[i].name;
        for (int j = 0; j < 3; j++)
        {
            cin >> stu[i].score1[j];
            stu[i].sum1 += stu[i].score1[j];
        }
        for (int j = 0; j < 3; j++)
        {
            cin >> stu[i].score2[j];
            stu[i].sum2 += stu[i].score2[j];
        }
        stu[i].totalstudy = stu[i].score1[0] + stu[i].score2[0];
        stu[i].sum3 = stu[i].sum1 + stu[i].sum2;
        if (stu[i].name == "crazyzhk") {
            ori[0] = stu[i].score1[0];
            ori[1] = stu[i].score2[0];
        }
    }
    cin >> m >> p >> q;
    long long ans = 1e18;
    for (int i = 0; ori[0] + i <= 100; i++)
    {
        for (int j = 0; ori[1] + j <= 100; j++)
        {
            init(i, j);
            if (check()) {
                //cout<<i<< " " << j << endl;
                ans = min(ans, (long long)i * p + j * q);
            }
        }
    }
    if (ans == (long long)1e18) {
        cout << "Surely next time" << endl;
        return 0;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 3584kb

input:

8
easycxk 94 12 77 74 70 55
hardzhk 80 80 95 96 20 60
crazyzhk 40 49 36 50 50 74
mike 50 98 93 36 90 23
amy 50 81 59 53 100 50
tom 50 71 69 53 90 60
john 65 73 41 60 34 69
jyy 12 26 29 29 53 50
2 44 14

output:

1494

result:

ok single line: '1494'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

7
a 30 61 27 94 20 70
b 64 57 68 8 43 34
c 97 66 94 33 79 42
crazyzhk 59 6 29 55 43 53
e 65 78 61 71 31 2
f 62 25 95 60 52 44
g 60 90 30 62 42 54
2 72 22

output:

858

result:

ok single line: '858'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

8
amy 94 12 77 100 70 55
hardzhk 90 80 95 96 20 60
john 90 39 16 70 50 74
mike 100 98 93 90 90 23
easycxk 70 81 59 73 100 50
ydzlhzs 100 85 89 100 90 60
crazyzhk 65 13 11 60 14 19
jyy 92 26 29 69 53 80
2 44 14

output:

Surely next time

result:

ok single line: 'Surely next time'

Test #4:

score: -100
Wrong Answer
time: 285ms
memory: 3584kb

input:

188
w 81 4 91 44 6 8
apbyloihyqjcrekq 73 30 30 39 56 4
fbrzsl 95 54 54 82 41 28
vkngftis 72 22 22 47 43 33
kehgasflquvcjed 43 68 53 5 26 49
efzjky 55 59 17 100 5 14
czockbgeibdncwekuwrq 11 61 71 21 18 21
eselhjadzufeonshb 96 5 91 15 67 14
mrvwolins 17 99 70 94 66 72
ona 43 27 26 63 54 19
trtdyfunitu...

output:

4068

result:

wrong answer 1st lines differ - expected: '2455', found: '4068'