QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49030 | #2281. BnPC | asdasdasfasdfasdfsdaf | WA | 2ms | 3592kb | C++ | 2.0kb | 2022-09-19 05:45:06 | 2022-09-19 05:45:07 |
Judging History
answer
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <functional>
struct action
{
uint64_t name;
int power;
action( uint64_t n, int p )
{
name = n; power = p;
}
};
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;
action_list.reserve( n );
char name[21];
int power;
for( int i = 0; i < n; i++ ) {
std::cin >> name; std::cin >> power;
action_list.emplace_back( std::hash<std::string>{}( name ), power );
}
int l;
std::cin >> l;
std::vector<action> event_list;
event_list.reserve( l );
for( int i = 0; i < l; i++ ) {
char name[21];
std::cin >> name; std::cin >> power;
event_list.emplace_back( std::hash<std::string>{}( name ), 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 aggression = 1;
if( k > 10000000 ) {
aggression = 1000;
}
int target_index = 0;
max_score = 0;
for( int i = 0; i < n; i++ ) {
action_list[i].power+= aggression;
int score = calculate_score( action_list, event_list );
if( score > max_score ) {
target_index = i;
max_score = score;
}
action_list[i].power- aggression;
}
action_list[target_index].power+= aggression;
k-= aggression;
}
std::cout << max_score;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3592kb
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:
142
result:
wrong answer 1st lines differ - expected: '82', found: '142'