QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648995 | #9370. Gambling on Choosing Regionals | huanxiel | WA | 1ms | 5620kb | C++20 | 2.2kb | 2024-10-17 21:13:07 | 2024-10-17 21:13:07 |
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)
b.push_back(a[i].w);
mp[a[i].name].push_back(a[i].w);
}
sort(all(b));
rep(i, 1, n)
{
int f = sz(mp[a[i].name]) >= mn && a[i].w < mp[a[i].name][mn - 1];
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: 0
Wrong Answer
time: 1ms
memory: 5620kb
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU
output:
1 0 1 2 1
result:
wrong answer 1st lines differ - expected: '2', found: '1'