QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648863 | #9370. Gambling on Choosing Regionals | huanxiel | WA | 41ms | 7484kb | C++20 | 2.1kb | 2024-10-17 20:45:26 | 2024-10-17 20:45:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
typedef double db;
const db eps = 1e-8;
#define inf 1e18
#define ret \
{ \
cout << -1 << endl; \
return; \
}
template <typename T>
bool gmax(T &x, const T y)
{
if (x < y)
return x = y, 1;
return 0;
}
template <typename T>
bool gmin(T &x, const T y)
{
if (y < x)
return x = y, 1;
return 0;
}
#define maxn 200003
struct node
{
int name;
int w, id;
bool friend operator<(node a, node b)
{
return a.w > b.w;
}
} a[maxn];
vector<int> mp[maxn];
int ans[maxn];
void solve()
{
map<string, int> m;
string s;
vector<int>b;
int n, k, x, mn = 1e9, cnt = 0;
cin >> n >> k;
rep(i, 1, k) cin >> x, gmin(mn, x);
rep(i, 1, n) {
cin >> a[i].w >> s, a[i].id = i;
if(!m[s]) m[s]=++cnt;
a[i].name=m[s];
}
sort(a + 1, a + 1 + n);
rep(i, 1, n)
{
if(sz(mp[a[i].name])<mn) mp[a[i].name].push_back(a[i].w),b.push_back(a[i].w);
}
sort(all(b));
rep(i,1,n)
{
int f=a[i].w<*mp[a[i].name].end();
int it=lower_bound(all(b),a[i].w)-b.begin()+1;
it=sz(b)-it;
ans[a[i].id]=it+1-f;
}
rep(i, 1, n) cout << ans[i] << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
// cin >> t;
while (t--)
solve();
}
// 循环边界
// 二分l和r的范围
// 数组越界
// 在函数内开数组赋初值
// long long
// 尽量用数学语言刻画
// 从直觉到严谨分析,推导
// 冷静,冷静,冷静
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5932kb
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU
output:
2 1 2 2 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 5932kb
input:
5 2 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU
output:
4 2 4 3 1
result:
ok 5 lines
Test #3:
score: 0
Accepted
time: 41ms
memory: 6244kb
input:
100000 100000 57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...
output:
1000 999 1000 1000 1000 1000 1000 1000 1000 869 1000 958 1000 1000 1000 1000 999 1000 1000 1000 1000 1000 1000 990 1000 1000 1000 631 1000 1000 1000 956 1000 1000 1000 1000 1000 1000 575 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 993 1000 1000 999 1000 995 1000 1...
result:
ok 100000 lines
Test #4:
score: -100
Wrong Answer
time: 35ms
memory: 7484kb
input:
100000 100000 67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...
output:
38094 68893 8008 72205 14144 6830 48241 54783 24826 22671 69968 63405 42977 34955 37073 72306 21662 58078 74211 68516 24344 37264 47307 18059 34775 56816 64113 72997 71481 13161 47438 48057 22609 73410 55895 53054 66204 5075 27380 71695 15008 61428 73977 50256 39523 68470 73731 20024 19546 73505 345...
result:
wrong answer 7th lines differ - expected: '48242', found: '48241'