QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49309#2281. BnPCasdasdasfasdfasdfsdafWA 0ms3624kbC++2.0kb2022-09-20 00:11:172022-09-20 00:11:18

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-20 00:11:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2022-09-20 00:11:17]
  • 提交

answer

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

struct AttributeInfo
{
	uint32_t amount_maxed = 0;
	uint32_t occurance = 0;
	uint32_t assigned_power;
};

int main()
{
	std::ios_base::sync_with_stdio( false );
	std::cin.tie( NULL );

	int n, k, l;
	std::cin >> n >> k;
	std::map<std::string, AttributeInfo> events;
	std::string name;
	uint32_t power;
	for( int i = 0; i < n; i++ ) {
		std::cin >> name >> power;
		events[name].assigned_power = power;
	}
	std::cin >> l;
	for( int i = 0; i < l; i++ ) {
		std::cin >> name >> power;
		AttributeInfo& info = events.at( name );
		info.occurance++;
		if( info.assigned_power == power ) {
		info.amount_maxed++;
		}
		else if( info.assigned_power < power ) {
			info.amount_maxed = 1;
			int delta = power - info.assigned_power;
			info.assigned_power += delta;
			k -= delta;
		}
	}

	if( k < 0 ) {
		std::cout << "0" << "\n";
	}
	int max_score = 0;
	int score = 0;
	int duplicates = 1;
	AttributeInfo* target = nullptr;
	while( k && duplicates) {
		max_score = 0;
		target = nullptr;
		for( auto& attribute_info : events ) {
			duplicates = attribute_info.second.amount_maxed;
			score = attribute_info.second.occurance + (duplicates * attribute_info.second.assigned_power);
			if( score > max_score ) {
				target = &attribute_info.second;
				max_score = score;
			}
		}
		if( target ) {
			target->amount_maxed = 0;
			target->assigned_power++;
			k--;
		}
	}
	max_score = 0;
	if( k ) {
		for( auto& attribute_info : events ) {
			score = attribute_info.second.occurance;
			if( score > max_score ) {
				target = &attribute_info.second;
				max_score = score;
			}
		}
		if( target != nullptr ) {
			target->assigned_power += k;
		}
	}
	score = 0;
	for( auto& attribute_info : events ) {
		score += ( attribute_info.second.occurance - attribute_info.second.amount_maxed ) * attribute_info.second.assigned_power;
	}

	std::cout << score << "\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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: -100
Wrong Answer
time: 0ms
memory: 3624kb

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:

329

result:

wrong answer 1st lines differ - expected: '429', found: '329'