QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49024#2281. BnPCasdasdasfasdfasdfsdafWA 3ms3616kbC++2.2kb2022-09-19 05:29:182022-09-19 05:29:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-19 05:29:21]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3616kb
  • [2022-09-19 05:29:18]
  • 提交

answer

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <functional>


struct action
{
    uint64_t name;
    int power;
};

inline int calculate_score( const std::vector<action>& actions, const std::vector<action>& events )
{
    int score = 0;
    for( const action& rAction : actions ) {
        for( const action& rEvent : events ) {
            if( rAction.name != rEvent.name )
                continue;
            if( rAction.power > rEvent.power )
                score += rAction.power;
        }
    }

    return score;
}

int main()
{
    int n, k;
    std::cin >> n; std::cin >> k;
    std::vector<action> action_list( n );
    for( int i = 0; i < n; i++ ) {
        char name[21];
        std::cin >> name;
        action_list[i].name = std::hash<std::string>{}( name );
        std::cin >> action_list[i].power;
    }

    int l;
    std::cin >> l;
    std::vector<action> event_list( l );


    for( int i = 0; i < l; i++ ) {
        char name[20];
        std::cin >> name;
        event_list[i].name = std::hash<std::string>{}( name );
        std::cin >> event_list[i].power;
    }

    for( action& rAction : action_list ) {
        for( const action& rEvent : event_list ) {
            if( rAction.name != rEvent.name )
                continue;
            if( rAction.power < rEvent.power ) {
                int delta = rEvent.power - rAction.power;
                rAction.power += delta;
                k -= delta;
                if( k < 0 ) {
                    std::cout << 0;
                    return 0;
                }
            }
        }
    }

    int max_score = 0;

    while( k ) {
        int target_index = 0;
        max_score = -1;
        for( int i = 0; i < n; i++ ) {
            action_list[i].power++;
            int score = calculate_score( action_list, event_list );
            if( score > max_score ) {
                target_index = i;
                max_score = score;
            }
            action_list[i].power--;
        }
        action_list[target_index].power++;
        k--;
    }

    std::cout << max_score;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3616kb

input:

3 14
THISISTHEONE 8
B 0
C 0
8
THISISTHEONE 10
C 0
B 1
B 0
THISISTHEONE 0
C 1
THISISTHEONE 0
THISISTHEONE 0

output:

82

result:

ok single line: '82'

Test #2:

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

input:

3 99
THEFIRSTINCREASE 6
SECONDINCREASE 4
ZZZ 1
9
THEFIRSTINCREASE 4
ZZZ 0
THEFIRSTINCREASE 6
SECONDINCREASE 8
THEFIRSTINCREASE 2
SECONDINCREASE 1
ZZZ 0
SECONDINCREASE 8
THEFIRSTINCREASE 3

output:

429

result:

ok single line: '429'

Test #3:

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

input:

5 20
A 100
B 200
C 300
D 400
E 500
949
A 39
A 23
C 163
A 98
B 36
A 3
A 52
B 152
B 167
B 65
C 142
B 66
B 117
C 288
C 155
E 341
A 97
D 173
E 31
A 62
D 90
E 361
A 42
D 85
E 1
C 141
B 77
B 194
D 221
E 203
D 345
E 48
B 26
D 46
B 74
E 380
B 181
C 243
B 112
A 99
E 403
C 20
E 453
C 149
B 26
E 245
A 74
D 304...

output:

285180

result:

ok single line: '285180'

Test #4:

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

input:

2 1
A 10
B 12
3
A 10
B 10
B 10

output:

35

result:

ok single line: '35'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3604kb

input:

1 1
OVERENTHUSIASTICNESS 41
1
OVERENTHUSIASTICNESS 0

output:

0

result:

wrong answer 1st lines differ - expected: '42', found: '0'