题解

4 条题解

  • 1
    @ 2020-11-16 09:25:47
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <deque>
    using namespace std;
    
    namespace dts
    {
        class segment
        {
            public:
                int l,r;
        };
        int cmp_segment(segment a,segment b)
        {
            return a.l<b.l||(a.l==b.l&&a.r<b.r);
        }
        
        int n,ans;
        segment s[25000];
        
        void main()
        {
            scanf("%d",&n);
            for (int i=0;i<n;i++)
                scanf("%d%d",&s[i].l,&s[i].r);
            sort(&s[0],&s[n],cmp_segment);
            ans=0;
            for (int i=0;i<n;i++)
            {
                int tmp=0;
                for (int j=i+1;j<n;j++)
                {
                    if (s[j].l>s[i].r)
                        break;
                    else if (s[j].r<=s[i].r)
                        tmp++;
                }
                ans=max(ans,tmp);
            }
            printf("%d\n",ans);
        }
    }
    
    int main()
    {
        dts::main();
    }
    
  • 0
    @ 2016-09-20 12:20:29

    大力出奇迹!如果有更好的解法,麻烦告诉QQ1409493554 XD

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 756 KiB, score = 9
    测试数据 #1: Accepted, time = 0 ms, mem = 752 KiB, score = 9
    测试数据 #2: Accepted, time = 0 ms, mem = 756 KiB, score = 9
    测试数据 #3: Accepted, time = 0 ms, mem = 752 KiB, score = 9
    测试数据 #4: Accepted, time = 0 ms, mem = 752 KiB, score = 9
    测试数据 #5: Accepted, time = 0 ms, mem = 752 KiB, score = 9
    测试数据 #6: Accepted, time = 15 ms, mem = 752 KiB, score = 9
    测试数据 #7: Accepted, time = 15 ms, mem = 756 KiB, score = 9
    测试数据 #8: Accepted, time = 125 ms, mem = 752 KiB, score = 9
    测试数据 #9: Accepted, time = 15 ms, mem = 752 KiB, score = 9
    测试数据 #10: Accepted, time = 234 ms, mem = 752 KiB, score = 10
    Accepted, time = 404 ms, mem = 756 KiB, score = 100
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    using namespace std;

    struct segment {
    int a, b;
    } seg[25010];

    int n, ans;

    inline bool cmp(segment a, segment b) { return a.a < b.a; }
    inline int max(int x, int y) { return x > y ? x : y; }

    int main() {
    scanf("%d", &n);
    int i, j, tmp;
    for(i = 0;i < n;i ++) scanf("%d%d", &seg[i].a, &seg[i].b);
    sort(seg, seg+n, cmp);
    for(i = 0;i < n;i ++) {
    tmp = 0;
    for(j = i+1;j < n;j ++) {
    if(seg[j].a > seg[i].b) break;
    if(seg[j].b <= seg[i].b) tmp ++;
    }
    ans = max(ans, tmp);
    }
    printf("%d", ans);
    return 0;
    }

  • 0
    @ 2016-04-09 16:45:09

    楼下智障

  • 0
    @ 2015-12-20 19:32:56

    虽然我没有AC但我来抢个沙发

  • 1

信息

ID
1802
难度
6
分类
(无)
标签
(无)
递交数
101
已通过
28
通过率
28%
被复制
1
上传者