QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#648829#9370. Gambling on Choosing RegionalshuanxielWA 52ms6216kbC++202.1kb2024-10-17 20:33:582024-10-17 20:34:00

Judging History

你现在查看的是最新测评结果

  • [2024-10-17 20:34:00]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:6216kb
  • [2024-10-17 20:33:58]
  • 提交

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, a[i].name = (m[s] ? m[s] : ++cnt), 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)
    {
        if(a[i].w<*mp[a[i].name].end()) 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;
    }
    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
// 尽量用数学语言刻画
// 从直觉到严谨分析,推导
// 冷静,冷静,冷静

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5844kb

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: 5676kb

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
Wrong Answer
time: 52ms
memory: 6216kb

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:

995
637
893
998
981
779
893
770
864
401
834
482
964
958
948
864
613
960
801
939
805
665
909
537
900
938
659
299
724
960
834
477
984
984
707
943
668
825
283
731
995
999
706
995
876
960
946
995
856
898
721
744
985
998
711
547
940
930
586
999
554
925
995
996
896
966
978
947
366
990
952
909
993
874
503
...

result:

wrong answer 1st lines differ - expected: '1000', found: '995'