QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#847111 | #5737. Remorse | Yarema# | AC ✓ | 1ms | 3812kb | C++20 | 1.1kb | 2025-01-07 17:25:43 | 2025-01-07 17:25:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string s;
getline(cin, s);
VI cnt(26);
FOR (i, 0, SZ(s))
{
if ('A' <= s[i] && s[i] <= 'Z')
s[i] += 'a' - 'A';
if ('a' <= s[i] && s[i] <= 'z')
cnt[s[i] - 'a']++;
}
sort(ALL(cnt), greater());
int total = accumulate(ALL(cnt), 0);
int ans = (total - 1)* 3;
VI lens;
FOR (l, 1, 7)
{
FOR (mask, 0, 1 << l)
{
int cost = l - 1;
FOR (j, 0, l)
{
if ((mask >> j) & 1)
cost += 3;
else
cost += 1;
}
lens.PB(cost);
}
}
sort(ALL(lens));
FOR (i, 0, 26)
ans += lens[i] * cnt[i];
cout << ans << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
ICPC
output:
17
result:
ok single line: '17'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
A
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
The quick brown dog jumps over the lazy fox.
output:
335
result:
ok single line: '335'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
Now is the time for all good men to come to the aid of their country. Fourscore and seven years ago our forefathers brought to this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.
output:
1607
result:
ok single line: '1607'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for th...
output:
179819
result:
ok single line: '179819'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
QZciVKAgzAHHDgABJMhJvnKIwdSNqnnLPHnIAtGmsKUAxLBrzdLmsingreHuegdzTCnEMXLNFAILkhIuPvLzMefxpJIFNduQBnJAhsAkTRripMtFsfQaBxpyKnpvGEcgjClfxiuMLKuKwvfpbUwkeRsiEkcywOnsGmybWoWihMwhaRlAXOdoaZcsQSXfQfghItUnsEjvJhHAYEYSHRwidLDjIgKgkCkNaIXlylXOTAsUXeJwVMbiVHHvrQOmdlNjEFMvKCzlFCvtwwYZQoVjkoqSUZqCGIbMeCwNWOpuHHYG...
output:
347243
result:
ok single line: '347243'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
QbeEZdbSySOxwJrwsfzRlqnxuFvdFLukHwFtCUbFkbrOarmSeREicvBYfnUA
output:
549
result:
ok single line: '549'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
iMOMNqgkeWjFejBWIifAthLQOUkDwjvWwqIFRHvTupZmbmaMlGfqEKnQEQdRWNQfXgCDGsLKhjaLEcOrnZdHeeRxlaBiLBCnFKyJVmZbkRkkMePkWDczHEpTOkDQgHVyNVZEoqTTOBkLovaOeiqmuKtYBAPizRgMFDCVPthTCiLPItNkMpPCnffsvcwlxMnOxmBFbkHoNLCkuIqiTeaRSyvbycMCcZVzujKBDqwMGciKiTyrMjRsDrNDEDRBOrQwOUDiGCYdKKbGznSEpYMzwgZiyVzAWXKzNOjTUVamYoUR...
output:
21965
result:
ok single line: '21965'