Laptop

Laptop

https://ac.nowcoder.com/acm/problem/14266

对所有计算机按照内存容量大小从大到小排序,然后顺序检索,看有没有下克上容量小但是速度超快的,有的话就更新最大基准值,没有的话就完爆数量+1。

所有的做法都是错的,建议牛客加强数据重判。

#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld", (x))
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
struct lap {
    ll a, b;
} p[N];
bool cmp(lap x, lap y) { return x.a > y.a; }
int main() {
    ll n;
    sc(n);
    for (ll i = 0; i < n; ++i) sc(p[i].a), sc(p[i].b);
    sort(p, p + n, cmp);
    ll mx = p[0].b, ans = 0;
    for (ll i = 1; i < n; ++i) 
        if (p[i].b <= mx)  ++ans;
        else mx = p[i].b;
    pr(ans);
    return 0;
}
算法竞赛之路 文章被收录于专栏

整理、记录算法竞赛的好题

全部评论

相关推荐

评论
9
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务