Galactic Collegiate Programming Contest Gym - 101572G 模拟

#include<bits/stdc++.h>
using namespace std;
int n,m;
struct node
{
    int id;
    int slove;
    int pen;
    bool operator<(const node &b)const
    {
        //如果解决的数量和罚时都一样,就按照序号排序
        if(slove==b.slove&&pen==b.pen)
            return id<b.id;
        //如果解决的数目不一样,就优先按照数目排序
        if(slove!=b.slove)
            return slove>b.slove;
        //再按照罚时排序
        return pen<b.pen;
    }
} a[200000];
set<node>s;
int main()
{
    cin>>n>>m;
    for (int i=1; i<=n; i++)
        a[i].id=i;
    for (int i=1; i<=m; i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        //删去,更新
        s.erase(a[l]);
        //解决数目++
        a[l].slove++;
        //罚时增加
        a[l].pen+=r;
        //如果更新的是第一个队
        if(l==1)
        {
            while (!s.empty()&& (a[1] < ( *(--s.end()) )))
                s.erase(--s.end());
        }
        else
        {
            if(a[l]<a[1])
                s.insert(a[l]);
        }
        cout<<s.size()+1<<endl;
    }
}

原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12349642.html

时间: 2024-10-22 04:54:07

Galactic Collegiate Programming Contest Gym - 101572G 模拟的相关文章

【离散化树状数组】Nordic Collegiate Programming Contest G.Galactic Collegiate Programming Contest

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 int n,m; 5 const int maxn=1e5+3; 6 struct node 7 { 8 int team; 9 int num; 10 int time; 11 int id; 12 }a[maxn]; 13 int ans[maxn]; 14 int b[maxn]; 15 int c[maxn]; 16 int s[maxn

(寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest

layout: post title: (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! 许老师! Hello SCPC 2018! (签到) #include<bits/stdc++.h> using namespace std; typedef

(寒假GYM开黑)2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)

layout: post title: 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! B.Baby Bites (签到模拟) 按照题意模拟就行了 int a[maxn]; string s; int main() { std::ios::syn

(寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! 许老师! B.Buildings (polya定理) 题意 B:给你m面墙,每面墙是n*n的格子,你有c种颜色,问你有多少种涂色方案.用po

(寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题)

layout: post title: (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces - DP - 状态压缩 - LCA 传送门 付队! C - Greetings! (状态压缩) 题意 给N种信件,你可以任意选择K种信封装信件,问你最少的浪费是多少 不能大的信件装

(寒假GYM开黑)2018 German Collegiate Programming Contest (GCPC 18)

layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队博客 C.Coolest Ski Route (记忆化搜索) 题意 给出一个有向图,求出一个权值最长的链, 题解 暴力dfs会超时,所以直接储存每个起点能走到的最远距离 #include<

2018 German Collegiate Programming Contest (GCPC 18)

2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <algorithm> #include <iterator> #include <iostream> #include <cstring> #include <cstdlib> #include <iomanip> #include <bit

2018 ACM-ICPC, Syrian Collegiate Programming Contest

2018 ACM-ICPC, Syrian Collegiate Programming Contest A Hello SCPC 2018! 水题 B Binary Hamming 水题 C Portals 思路:并查集维护连通性 代码: //#pragma GCC optimize(3) //#pragma comment(linker, "/STACK:102400000,102400000") //c++ // #pragma GCC diagnostic error &quo

ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018

ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018 Problem A. Can Shahhoud Solve it? Problem B. Defeat the Monsters Problem C. UCL Game Night Problem