1 条题解

  • 0
    @ 2024-11-19 18:00:34

    将醒着的时刻和睡着的时刻标记一下即可。

    #include <bits/stdc++.h>
    
    using i64 = long long;
    using u32 = unsigned;
    using u64 = unsigned long long;
    
    int main() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    
     	int n;
     	std::cin >> n;
    
     	std::vector<int> s(n + 1, 1);
     	for (int i = 0; i < 6; ++i) {
     		int a, b;
     		std::cin >> a >> b;
     		for (int j = a; j <= std::min(b + 3, n); ++j) {
     			s[j] = 0;
     		}
     	}
    
     	int ans = 0;
     	for (int i = 0; i <= n; ++i) {
     		ans += s[i];
     	}
    
     	std::cout << ans;
    
        return 0;
    }
    
    • 1

    信息

    ID
    138
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    104
    已通过
    22
    上传者