3304. 不等式

我太难了

eoj太猛了,就一顿暴搜。

#include <bits/stdc++.h>
using namespace std;
vector<int> eq, gre, le, egre, ele;
int ma = 1, pos = 1;

void solve(int x){
    for (auto j : gre)
        if (x > j)
            pos++;
    for (auto j : le)
        if (x < j)
            pos++;
    for (auto j : egre)
        if (x >= j)
            pos++;
    for (auto j : ele)
        if (x <= j)
            pos++;
    ma = max(pos, ma);
    pos = 1;
}

int main(){
    int n;
    cin >> n;
    while (n--){
        string s;
        int c;
        cin >> s >> s >> c;
        if (s == "=")
            eq.push_back(c);
        else if (s == ">")
            gre.push_back(c);
        else if (s == "<")
            le.push_back(c);
        else if (s == "<=")
            ele.push_back(c);
        else
            egre.push_back(c);
    }
    for (auto i : eq)
        solve(i);
    for (auto i : gre)
        solve(i);
    for (auto i : le)
        solve(i);
    for (auto i : egre){
        pos = 0;
        solve(i);
    }
    for (auto i : ele){
        pos = 0;
        solve(i);
    }
    cout << ma;
}
CCXXXI_

动态语言真是太棒啦(。・∀・)ノ゙


expr = list(input().replace(' =', '==') for _ in range(int(input())))
xs = set(int(e.split()[-1]) for e in expr)
xs |= set(x + 1 for x in xs) | set(x - 1 for x in xs)
print(max(sum(eval(e, {'X': x}) for e in expr) for x in xs))

动态语言真是太慢啦ಥ_ಥ

你当前正在回复 博客/题目
存在问题!