QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49326 | #2281. BnPC | asdasdasfasdfasdfsdaf | RE | 189ms | 14752kb | C++23 | 2.1kb | 2022-09-20 05:01:57 | 2022-09-20 05:02:00 |
Judging History
answer
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <functional>
#include <algorithm>
struct AttributeInfo
{
uint64_t amount_maxed = 0;
uint64_t occurance = 0;
uint64_t assigned_power;
};
int main()
{
std::ios_base::sync_with_stdio( false );
std::cin.tie( NULL );
uint64_t n, k, l;
std::cin >> n >> k;
std::map<std::string, AttributeInfo> events;
std::string name;
uint64_t power;
for( uint64_t i = 0; i < n; i++ ) {
std::cin >> name >> power;
events[name].assigned_power = power;
}
std::cin >> l;
std::pair<uint64_t, AttributeInfo*> greatest_occurance;
for( uint64_t 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<uint64_t, AttributeInfo*>( info.occurance, &info );
}
if( info.assigned_power == power ) {
info.amount_maxed++;
} else if( info.assigned_power < power ) {
info.amount_maxed = 1;
uint64_t delta = power - info.assigned_power;
info.assigned_power += delta;
k -= delta;
}
}
if( k == 0 ) {
std::cout << 0 << "\n";
return 0;
}
std::vector < std::pair<uint64_t, AttributeInfo*>> score_list;
for( auto& score_counter : events ) {
uint64_t 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() );
uint64_t 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;
}
uint64_t 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: 100
Accepted
time: 1ms
memory: 3612kb
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: 2ms
memory: 3532kb
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: 2ms
memory: 3552kb
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: 3692kb
input:
2 1 A 10 B 12 3 A 10 B 10 B 10
output:
35
result:
ok single line: '35'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
1 1 OVERENTHUSIASTICNESS 41 1 OVERENTHUSIASTICNESS 0
output:
42
result:
ok single line: '42'
Test #6:
score: 0
Accepted
time: 110ms
memory: 14656kb
input:
100000 1000000000 A 1000000000 B 1000000000 C 1000000000 D 1000000000 E 1000000000 F 1000000000 G 1000000000 H 1000000000 I 1000000000 J 1000000000 K 1000000000 L 1000000000 M 1000000000 N 1000000000 O 1000000000 P 1000000000 Q 1000000000 R 1000000000 S 1000000000 T 1000000000 U 1000000000 V 1000000...
output:
100007999593560
result:
ok single line: '100007999593560'
Test #7:
score: 0
Accepted
time: 189ms
memory: 14752kb
input:
100000 1000000000 A 1000000000 B 1000000000 C 1000000000 D 1000000000 E 1000000000 F 1000000000 G 1000000000 H 1000000000 I 1000000000 J 1000000000 K 1000000000 L 1000000000 M 1000000000 N 1000000000 O 1000000000 P 1000000000 Q 1000000000 R 1000000000 S 1000000000 T 1000000000 U 1000000000 V 1000000...
output:
100006999854911
result:
ok single line: '100006999854911'
Test #8:
score: -100
Runtime Error
input:
1 1000000000 A 1000000000 100000 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0 A 0...