编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#4827 #1028. 愤怒的小鸟 Compile Error 0 0 ms 0 K C++ 17 / 495 B t330026229 2024-02-20 19:19:21
显示原始代码
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int n, k, l, r, flag[N], min = 5e5, max = 0;
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> l >> r;
        l = l < 0 ? 0 : l;
        if (min > l)
            min = l;
        if (max < r)
            max = r;
        for (int j = l; j <= r; j++) flag[j] = 1;
    }
    long long cnt = 0LL;
    for (int i = min; i <= max; i += k) {
        if (flag[i] == 1)
            cnt++;
        while (flag[i] == 0) i++;
    }
    cout << cnt << endl;
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:12:13: error: reference to 'min' is ambiguous
   12 |         if (min>l) min=l;
      |             ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:                 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:26: note:                 'int min'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                          ^~~
/sandbox/1/a.cpp:12:20: error: reference to 'min' is ambiguous
   12 |         if (min>l) min=l;
      |                    ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:                 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:26: note:                 'int min'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                          ^~~
/sandbox/1/a.cpp:13:13: error: reference to 'max' is ambiguous
   13 |         if (max<r) max=r;
      |             ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:35: note:                 'int max'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                                   ^~~
/sandbox/1/a.cpp:13:20: error: reference to 'max' is ambiguous
   13 |         if (max<r) max=r;
      |                    ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:35: note:                 'int max'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                                   ^~~
/sandbox/1/a.cpp:17:16: error: reference to 'min' is ambiguous
   17 |     for (int i=min;i<=max;i+=k)
      |                ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:                 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:26: note:                 'int min'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                          ^~~
/sandbox/1/a.cpp:17:23: error: reference to 'max' is ambiguous
   17 |     for (int i=min;i<=max;i+=k)
      |                       ^~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:65,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:                 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/stdc++.h:41,
                 from /sandbox/1/a.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:                 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/sandbox/1/a.cpp:4:35: note:                 'int max'
    4 | int n, k, l, r, flag[N], min=5e5, max=0;
      |                                   ^~~