zoukankan      html  css  js  c++  java
  • hihocoder #1223 : 不等式 水题

    #1223 : 不等式

    Time Limit: 1 Sec  

    Memory Limit: 256 MB

    题目连接

    http://hihocoder.com/problemset/problem/1223

    Description

    给定n个关于X的不等式,问最多有多少个成立。

    每个不等式为如下的形式之一:

    X < C

    X <= C

    X = C

    X > C

    X >= C

    Input

    第一行一个整数n。

    以下n行,每行一个不等式。

    数据范围:

    1<=N<=50,0<=C<=1000

    Output

    一行一个整数,表示最多可以同时成立的不等式个数。

    Sample Input

    4
    X = 1
    X = 2
    X = 3
    X > 0

    Sample Output

    2


    HINT

     

    题意

    题解:

    直接枚举每一个数就好了,对于每一个数,判断有多少个数据是满足的

    当然对于数据范围比较大的题的话,那就得离散化加区间更新呢,最后查询最大值就好了

    总体来说思路是一样的

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <bitset>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 1200051
    #define mod 10007
    #define eps 1e-9
    int Num;
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=~0u>>1;
    inline 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;
    }
    //**************************************************************************************
    
    
    string str[100],X;
    int num[100];
    int main()
    {
        int n=read();
        for(int i=1;i<=n;i++)
        {
            cin>>X>>str[i]>>num[i];
            num[i]*=2;
        }
        int ans=0;
        for(int i=-2;i<=2002;i++)
        {
            int tmp = 0;
            for(int j=1;j<=n;j++)
            {
                int ok = 1;
                if(str[j]=="<")
                    if(i>=num[j])
                        ok=0;
                if(str[j]=="<=")
                    if(i>num[j])
                        ok=0;
                if(str[j]=="=")
                    if(i!=num[j])
                        ok=0;
                if(str[j]==">")
                    if(i<=num[j])
                        ok=0;
                if(str[j]==">=")
                    if(i<num[j])
                        ok=0;
                if(ok)
                    tmp++;
            }
            ans=max(tmp,ans);
        }
        printf("%d
    ",ans);
    }
  • 相关阅读:
    Burp Suite Professional单文件精简版该如何使用?
    快速掌握WinDBG
    Baymax大白补丁打油诗
    学员达标后完成的作业
    5星命名法:掌握这个软件全省
    挖掘IDA不可缺少的插件
    JEB安装和使用视频教程系列
    Ollydbg/x32dbg/x64dbg堆栈回溯要点总结
    Ollydbg狩猎从入门到精通
    Ollydbg/x32dbg爆破与逆向八法
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4772873.html
Copyright © 2011-2022 走看看