首页 > 其他分享 >Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新

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

时间:2023-04-24 22:39:12浏览次数:43  
标签:return NCPC Contest int tt Programming score team include


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;
}


标签:return,NCPC,Contest,int,tt,Programming,score,team,include
From: https://blog.51cto.com/u_15657999/6221926

相关文章

  • The 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
    ThetunnelsofCuChiareanimmensenetworkofundergroundtunnelsconnectingroomslocatedintheCuChiDistrictofHoChiMinhCity.TheCuChitunnelswerethelocationofseveralmilitarycampaignsinthe1960s.Nowadays,itisapopulartouristdes......
  • ACM International Collegiate Programming Contest 2014 B SPFA 统计路径
    FloweryTrails!”()”*+,-).%”/)’0”122”1!2”342”522”!22”652”!42”72”72”5!2”!12”622”18!”162”!12”6”7”4”9”3”5”8”1”2”Inordertoattractmorevisitors,themanagerofanationalp......
  • ACM International Collegiate Programming Contest 2014 A dfs 好题
    GREAT+SWERC=PORTOWewanttohaveagreatSWERCatPortothisyearandweapproachedthischallengeinseveralways.Weevenframeditasawordadditionproblem,similartotheclassicSEND+MORE=MONEY,whereeachletterstandsforasingledigit(......
  • [CMU 15-418] (Lecture4) Parallel Programming Basics
    本系列文章为CMU15-418/15-618:ParallelComputerArchitectureandProgramming,Fall2018课程学习笔记课程官网:CMU15-418/15-618:ParallelComputerArchitectureandProgramming参考文章:CMU15-418notes相关资源与介绍:CMU15-418/StanfordCS149:ParallelComput......
  • AtCoder Beginner Contest 158
    AtCoderBeginnerContest158https://atcoder.jp/contests/abc158基础不牢,地动山摇D-StringFormation一个小小的STL应用#include<bits/stdc++.h>#definelllonglongusingnamespacestd;strings;intq,t,f;charc;intmain(){cin>>s>>q......
  • AtCoder Regular Contest 111 F Do you like query problems?
    洛谷传送门AtCoder传送门挺有意思的计数。计数感觉很难做,不妨转成期望,期望又可以转成概率之和。考虑枚举\(w\in[0,m-1]\),把\(>w\)的数设为\(1\),\(\lew\)的数设为\(0\)。那么期望就是所有\(w\),\(a_i\)为\(1\)的概率之和。对于一个\(i\),只有以下的操作能改变\(......
  • SMU Spring 2023 Trial Contest Round 9
    SMUSpring2023TrialContestRound9A-WrongSubtraction#include<bits/stdc++.h>usingnamespacestd;typedefpair<int,int>PII;typedefpair<string,int>PSI;constintN=1e5+5,INF=0x3f3f3f3f,Mod=1e6;constdoubleeps=1e-6;typedefl......
  • SMU Spring 2023 Trial Contest Round 9
    A.WrongSubtraction#include<bits/stdc++.h>usingnamespacestd;int32_tmain(){intn,k;cin>>n>>k;while(k--){if(n%10==0)n/=10;elsen--;}cout<<n;return0;}B.T......
  • Atcoder Beginner Contest 299 G
    对于要打印的\(B\),我们首先尝试确定\(B_1\)。让\(f(x)(1≤x≤M)\)是最大的\(i\),使\(A_i=x\)。对于\(r:=\underset{{{1≤x≤M}}}{\min}f(x)\),我们可以证明\(B_1\)是\(A_1,A_2,...,A_r\)中的一个(否则,\(B\)是\(A_{>r}:=(A_r+1,Ar+2,...,A_N)\)的一个子序列,但......
  • AtCoder Beginner Contest 283 Ex Popcount Sum
    洛谷传送门AtCoder传送门记录一下这个神奇的套路。首先有\(\operatorname{popcount}(n)=n-\sum\limits_{i=1}^{\infty}\left\lfloor\frac{n}{2^i}\right\rfloor\)。证一下:\[\operatorname{popcount}(n)=\sum\limits_{i=0}^{\infty}\left\lfloor\dfrac{n}{2^i}\right......