QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648658 | #9370. Gambling on Choosing Regionals | huanxiel | TL | 3ms | 11612kb | C++20 | 2.2kb | 2024-10-17 19:51:08 | 2024-10-17 19:51:09 |
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
{
string s;
int w, id;
bool friend operator<(node a, node b)
{
return a.w > b.w;
}
} a[maxn];
map<string, vector<int>> mp;
int ans[maxn];
void solve()
{
int n, k, x, mn = 1e9;
cin >> n >> k;
rep(i, 1, k) cin >> x, gmin(mn, x);
rep(i, 1, n) cin >> a[i].w >> a[i].s, a[i].id = i;
sort(a + 1, a + 1 + n);
rep(i, 1, n)
{
for (auto team : mp)
{
vector<int>&b=team.second;
if (lower_bound(all(b), a[i].w) != b.end())
{
int it = lower_bound(all(b), a[i].w) - b.begin();
it = sz(b) - it;
//>cout<<i<<" "<<it<<endl;
if (team.first == a[i].s && it >= mn)
it = mn - 1;
else
gmin(it, mn);
ans[a[i].id] += it;
}
}
ans[a[i].id]++;
mp[a[i].s].push_back(a[i].w);
}
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: 3ms
memory: 11488kb
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: 3ms
memory: 11612kb
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: -100
Time Limit Exceeded
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 ...