编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#2366 #1004. 提瓦特大冒险 Compile Error 0 0 ms 0 K C++ 17 / 856 B xhlm 2023-11-17 11:56:09
显示原始代码
#include <bits/stdc++.h>
using namespace std;

const int max = 500001;
int a[max], x[max], y[max];
bool dp[max][max];

int main() {
    int n, m, t;
    cin >> n >> m >> t;
    for (int i = 1; i < n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> x[i] >> y[i];
    dp[1][t] = true;
    for (int i = 1; i < n; i++) {
        for (int j = a[i]; j <= t; j++) {
            if (dp[i][j]) {
                dp[i + 1][j - a[i]] = true;
                for (int k = 1; k <= m; k++) {
                    if (x[k] == i && j + y[k] <= t) {
                        dp[i + 1][j + y[k] - a[i]] = true;
                    }
                }
            }
        }
    }
    for (int j = 0; j <= t; j++) {
        if (dp[n][j]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

编译信息

/sandbox/1/a.cpp:5:7: error: reference to 'max' is ambiguous
    5 | int a[max], x[max], y[max];
      |       ^~~
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:11: note:                 'const int max'
    4 | const int max =500001;
      |           ^~~
/sandbox/1/a.cpp:5:15: error: reference to 'max' is ambiguous
    5 | int a[max], x[max], y[max];
      |               ^~~
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:11: note:                 'const int max'
    4 | const int max =500001;
      |           ^~~
/sandbox/1/a.cpp:5:23: error: reference to 'max' is ambiguous
    5 | int a[max], x[max], y[max];
      |                       ^~~
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:11: note:                 'const int max'
    4 | const int max =500001;
      |           ^~~
/sandbox/1/a.cpp:6:9: error: reference to 'max' is ambiguous
    6 | bool dp[max][max];
      |         ^~~
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:11: note:                 'const int max'
    4 | const int max =500001;
      |           ^~~
/sandbox/1/a.cpp:6:14: error: reference to 'max' is ambiguous
    6 | bool dp[max][max];
      |              ^~~
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:11: note:                 'const int max'
    4 | const int max =500001;
      |           ^~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:11:39: error: 'a' was not declared in this scope
   11 |     for(int i = 1; i < n; i++) cin >> a[i];
      |                                       ^
/sandbox/1/a.cpp:12:40: error: 'x' was not declared in this scope
   12 |     for(int i = 1; i <= m; i++) cin >> x[i] >> y[i];
      |                                        ^
/sandbox/1/a.cpp:12:48: error: 'y' was not declared in this scope
   12 |     for(int i = 1; i <= m; i++) cin >> x[i] >> y[i];
      |                                                ^
/sandbox/1/a.cpp:13:5: error: 'dp' was not declared in this scope
   13 |     dp[1][t] = true;
      |     ^~
/sandbox/1/a.cpp:15:21: error: 'a' was not declared in this scope
   15 |         for(int j = a[i]; j <= t; j++) {
      |                     ^
/sandbox/1/a.cpp:19:24: error: 'x' was not declared in this scope
   19 |                     if(x[k] == i && j + y[k] <= t) {
      |                        ^
/sandbox/1/a.cpp:19:41: error: 'y' was not declared in this scope
   19 |                     if(x[k] == i && j + y[k] <= t) {
      |                                         ^