HDU 5596 GTW likes gt 暴力~

本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、Unity、Cocos2d等,以及AI音视频处理技术的应用,如视频分割、语义识别、语音识别等。通过实例解析,为开发者提供全面的技术指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GTW likes gt

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 214 Accepted Submission(s): 71

Problem Description
Long long ago, there were n adorkable GT. Divided into two groups, they were playing games together, forming a column. The i−th GT would randomly get a value of ability bi. At the i−th second, the i−th GT would annihilate GTs who are in front of him, whose group differs from his, and whose value of ability is less than his.

In order to make the game more interesting, GTW, the leader of those GTs, would emit energy for m times, of which the i−th time of emitting energy is ci. After the ci second, b1,b2,…,bci would all be added 1.

GTW wanted to know how many GTs would survive after the n−th second.

Input
The first line of the input file contains an integer T(≤5), which indicates the number of test cases.

For each test case, there are n+m+1 lines in the input file.

The first line of each test case contains 2 integers n and m, which indicate the number of GTs and the number of emitting energy, respectively.(1≤n,m≤50000)

In the following n lines, the i−th line contains two integers ai and bi, which indicate the group of the i−th GT and his value of ability, respectively. (0≤ai≤1,1≤bi≤106)

In the following m lines, the i−th line contains an integer ci, which indicates the time of emitting energy for i−th time.

Output
There should be exactly T lines in the output file.

The i−th line should contain exactly an integer, which indicates the number of GTs who survive.

Sample Input
1
4 3
0 3
1 2
0 3
1 1
1
3
4

Sample Output
3
Hint
After the first seconds,b1=4,b2=2,b3=3,b4=1
After the second seconds,b1=4,b2=2,b3=3,b4=1
After the third seconds,b1=5,b2=3,b3=4,b4=1,and the second GT is annihilated by the third one.
After the fourth seconds,b1=6,b2=4,b3=5,b4=2
ci is unordered.

Source
BestCoder Round #66 (div.2)

基本思路:仔细看题你可以发现,如果你是从后往前扫的话,其实你可以先直接吧M次所谓的“发功”操作给做了,而且做了之后并不会影响最终结果。

所谓的发功就是对1-Ci 区间进行+1的操作,用差分约束就可以了~

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

const int maxx = 50000+10;
int p[maxx];
int kis[maxx];
int vis[maxx];
int n, m;
int T;

int main( ){
    cin>>T;
    while(T--){
        scanf("%d%d",&n,&m);
        for(int i = 0;i <= n+1 ; ++i) kis[i] = 0;
        for(int i = 1;i <= n; ++i){
            scanf("%d%d",&vis[i],&p[i]);
        }
        for(int i = 1;i <= m; ++i){
            int x;
            scanf("%d",&x);
            kis[1]++;
            kis[x+1]--;
        }
        int sum = 0;
        for(int i = 1;i <= n; ++i){
            sum+=kis[i];
            p[i]+=sum;
        }
        int t[2];
        t[0]=t[1]=-1;
        int ans = n;
        for(int i = n;i >= 1; --i){
            if(t[vis[i]]==-1){
                t[vis[i]] = p[i];
            }else if(t[vis[i]] < p[i]){
                t[vis[i]] = p[i];
            }
            if(t[!vis[i]]!=-1 && t[!vis[i]] > p[i]){
                ans--;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

若发现BUG请留言,或直接与我联系:hh_0828@outlook.com
不胜感激~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值