首页 > 其他分享 >abc080d <区间重叠>

abc080d <区间重叠>

时间:2023-07-12 09:45:20浏览次数:35  
标签:abc080d int long ans solv using include

D - Recording

// https://atcoder.jp/contests/abc080/tasks/abc080_d
#include <iostream>
#include <algorithm>
using namespace std;
using LL = long long;
const int N = 1e5 + 10;
int a[N][31];

void solv()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
    {
        int s, t, c;
        cin >> s >> t >> c;
        a[s][c] ++;
        a[t+1][c] --;
        // 这里实际上可以不前缀和, 直接 i <- s : t 进行标记
        // 复杂度不是 1e5*1e5, 因为同c情况下, 区间不重叠
    }
    int ans = 0;
    for (int i = 1; i < N; i ++)
    {
        int tot = 0;
        for (int j = 1; j <= m; j ++)
        {
            a[i][j] += a[i-1][j];
            // tot += a[i][j];  // 为什么这样写就会 WA 2 呢 ?
            tot += a[i][j] > 0;
        }
        ans = max(ans, tot);
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1;
	// cin >> T;
    while (T --)
    {
        solv();
    }
    return 0;
}

标签:abc080d,int,long,ans,solv,using,include
From: https://www.cnblogs.com/o2iginal/p/17546631.html

相关文章