Submission #157216

#TimeUsernameProblemLanguageResultExecution timeMemory
157216manh9203스트랩 (JOI14_straps)C++17
Compilation error
0 ms0 KiB
using namespace std; #define fi first #define se second const int N = 2e3 + 5; long long n,dp[N][N]; pair<long long,int> rope[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i=1;i<=n;i++) cin >> rope[i].fi >> rope[i].se; for(int i=0;i<=n;i++){ for(int j=1;j<=n;j++){ dp[i][j] = -1e18; } } sort(rope+1, rope+1+n); for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se; dp[i][j] = max(dp[i][j], dp[i-1][j]); } } cout << max(dp[n][0], dp[n][1]); }

Compilation message (stderr)

straps.cpp:6:1: error: 'pair' does not name a type
 pair<long long,int> rope[N];
 ^~~~
straps.cpp: In function 'int main()':
straps.cpp:8:2: error: 'ios_base' has not been declared
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ^~~~~~~~
straps.cpp:8:32: error: 'cin' was not declared in this scope
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                                ^~~
straps.cpp:8:32: note: suggested alternative: 'main'
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                                ^~~
                                main
straps.cpp:8:44: error: 'cout' was not declared in this scope
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                                            ^~~~
straps.cpp:10:31: error: 'rope' was not declared in this scope
  for(int i=1;i<=n;i++) cin >> rope[i].fi >> rope[i].se;
                               ^~~~
straps.cpp:16:7: error: 'rope' was not declared in this scope
  sort(rope+1, rope+1+n);
       ^~~~
straps.cpp:16:2: error: 'sort' was not declared in this scope
  sort(rope+1, rope+1+n);
  ^~~~
straps.cpp:16:2: note: suggested alternative: 'short'
  sort(rope+1, rope+1+n);
  ^~~~
  short
straps.cpp:19:27: error: 'min' was not declared in this scope
    dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
                           ^~~
straps.cpp:19:27: note: suggested alternative: 'main'
    dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
                           ^~~
                           main
straps.cpp:19:15: error: 'max' was not declared in this scope
    dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
               ^~~
straps.cpp:19:15: note: suggested alternative: 'main'
    dp[i][j] = max(dp[i-1][min(n, j + rope[i].fi - 1)], dp[i-1][j-1]) + rope[i].se;
               ^~~
               main
straps.cpp:23:10: error: 'max' was not declared in this scope
  cout << max(dp[n][0], dp[n][1]);
          ^~~
straps.cpp:23:10: note: suggested alternative: 'main'
  cout << max(dp[n][0], dp[n][1]);
          ^~~
          main