QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49380 | #2281. BnPC | krystofmitka | WA | 2ms | 3652kb | C++ | 3.5kb | 2022-09-20 18:26:27 | 2022-09-20 18:26:28 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <list>
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
#include <functional>
#include <unordered_map>
#include <unordered_set>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef long long ll;
#define O(i) i & 1
#define E(i) !O(i)
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n; cin >> n;
ll k; cin >> k;
unordered_map<string, ll> current;
unordered_map<string, vector<ll>> maxFreq;
while (n--) {
string a; cin >> a;
ll s; cin >> s;
current[a] = s;
maxFreq[a] = vector<ll>(3, 0);
}
ll l; cin >> l;
ll highestFreq = 0;
vector<pair<string, ll>> thingies;
while(l--) {
string a; cin >> a;
ll t; cin >> t;
thingies.push_back(make_pair(a,t));
maxFreq[a][0] = max(maxFreq[a][0], t);
maxFreq[a][1]++;
if (maxFreq[a][1] > highestFreq) {
highestFreq = maxFreq[a][1];
}
}
ll ans = 0;
priority_queue<ll> q;
unordered_set<string> mZero;
for ( const auto &p : current ) {
vector<ll> mxF = maxFreq[p.first];
ll diff = p.second - mxF[0];
if (diff <= 0) {
k = k + diff;
if ((mxF[0] + 1) * mxF[1] > highestFreq) {
q.push((mxF[0] + 1) * mxF[1]);
mZero.insert(p.first);
}
} else if (diff > 0) {
ans = ans + mxF[0] * mxF[1];
}
if (k < 0) {
cout << '0' << '\n';
return 0;
}
}
while(k > 0 && !q.empty()) {
ans = ans + q.top();
q.pop();
k--;
}
for ( const auto &p : thingies ) {
if (!mZero.count(p.first)) {
ll diff = maxFreq[p.first][0] - p.second;
ans = ans + max(0ll, diff);
}
}
cout << ans + k*highestFreq << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3652kb
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: 2ms
memory: 3536kb
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:
427
result:
wrong answer 1st lines differ - expected: '429', found: '427'