QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49318#2281. BnPCasdasdasfasdfasdfsdafWA 3ms3660kbC++232.0kb2022-09-20 04:41:492022-09-20 04:41:52

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 04:41:52]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3660kb
  • [2022-09-20 04:41:49]
  • 提交

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;
	std::pair<uint32_t, AttributeInfo*> greatest_occurance;
	for( int i = 0; i < l; i++ ) {
		std::cin >> name >> power;
		AttributeInfo& info = events.at( name );
		info.occurance++;
		if( info.occurance > greatest_occurance.first ) {
			greatest_occurance = std::pair<uint32_t, AttributeInfo*>( info.occurance, &info );
		}
		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;
		}
	}

	std::cout << greatest_occurance.first << "\n";

	std::vector < std::pair<uint32_t, AttributeInfo*>> score_list;
	for( auto& score_counter : events ) {
		int to_gain = score_counter.second.occurance + ( score_counter.second.amount_maxed * score_counter.second.assigned_power );
		score_list.emplace_back( to_gain, &score_counter.second );
	}

	std::sort( score_list.begin(), score_list.end() );

	int z = score_list.size() - 1;
	while( k && score_list[z].first > greatest_occurance.first && z > 0 ) {
		score_list[z].second->assigned_power++;
		score_list[z].second->amount_maxed=0;
		k--;
		z--;
	}

	if( k ) {
		greatest_occurance.second->assigned_power += k;
	}


	int score = 0;
	for( const auto& score_counter : events ) {
		score += score_counter.second.assigned_power * ( score_counter.second.occurance - score_counter.second.amount_maxed );
	}

	std::cout << score << '\n';

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3660kb

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:

4
82

result:

wrong answer 1st lines differ - expected: '82', found: '4'