Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新

One hundred years from now, in 2117, the International Collegiate Programming Contest (of which the NCPC is a part) has expanded significantly and it is now the Galactic Collegiate Programming Contest (GCPC).
This year there are n teams in the contest. The teams are numbered 1,2,…,n, and your favorite team has number 1.

Like today, the score of a team is a pair of integers (a,b) where a is the number of solved problems and b is the total penalty of that team. When a team solves a problem there is some associated penalty (not necessarily calculated in the same way as in the NCPC – the precise details are not important in this problem). The total penalty of a team is the sum of the penalties for the solved problems of the team.

Consider two teams t1 and t2 whose scores are (a1,b1) and (a2,b2). The score of team t1 is better than that of t2 if either a1>a2, or if a1=a2 and b1

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<string>
typedef long long ll;
using namespace std;
typedef unsigned long long int ull;
#define maxn 200005
#define inf 0x3f3f3f3f
const long long int mod = 1e9 + 7;

ll read() {
    ll x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') {
        if (ch == '-') {
            f = -1;
        }
        ch = getchar();
    }
    while (ch >= '0'&&ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

ll quickpow(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b % 2)ans = ans * a;
        b = b / 2;
        a = a * a;
    }
    return ans;
}

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a%b);
}




ll ves[maxn];
void revs() {
    for (ll i = 1; i <= 1000000; i++) {
        ves[i] = quickpow(i, mod - 2);
    }
}


//ull Mod = quickpow(2ull, 47ull);

queue<int>Q; queue<int>tmp;
int n, m;
int res;
struct Sco {
    int score, pena;
}tt[maxn];
bool inqueue[maxn];
bool cmp(int a, int b) {
    if (tt[a].score > tt[b].score)return true;
    if (tt[a].score == tt[b].score&&tt[a].pena < tt[b].pena)
        return true;
    return false;
}

void refr() {
    res = 1;
    while (!Q.empty()) {
        int team = Q.front(); Q.pop();
        if (cmp(team, 1)) {
            tmp.push(team); res++;
        }
        else {
            inqueue[team] = false;
        }
    }
    while (!tmp.empty()) {
        int team = tmp.front(); tmp.pop();
        Q.push(team);
    }
    return;
}
void judg() {
    int team, pen;
    cin >> team >> pen;
    if (team == 1) {
        tt[team].score++;
        tt[team].pena += pen;
        refr();
        cout << res << endl;
        return;
    }
    else {
        tt[team].score++;
        tt[team].pena += pen;
        if (inqueue[team] == true) {
            cout << res << endl;
        }
        else {
            if (cmp(team, 1)) {
                Q.push(team);
                inqueue[team] = true;
                res++;
                cout << res << endl;
                return;
            }
            else {
                cout << res << endl; return;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    res = 1;
    for (int i = 0; i < m; i++)judg();
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值