/ SeriousOJ /

Record Detail

Compile Error

foo.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(3,0));
  for (int i = 0; i < n; i++) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b[i];
    dp[i + 1][2] = max(dp[i][1], dp[i][0]) + c[i];
  }
  cout << *max_element(dp.back().begin(), dp.back().end()) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1046 Maximum sum in 3-array
Language
C99 (GCC 13.2.0)
Submit At
2024-07-14 09:36:57
Judged At
2024-11-11 03:26:17
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes