Submission #1036032

# Submission time Handle Problem Language Result Execution time Memory
1036032 2024-07-27T02:29:55 Z May27_th Triple Jump (JOI19_jumps) C++17
0 / 100
4000 ms 1112 KB
#include<bits/stdc++.h>
using namespace std;
#define i64 long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
void Solve(void) {
  int N; cin >> N;
  vector<int> a(N + 1);
  for (int i = 1; i <= N; i ++) cin >> a[i];
  int Q; cin >> Q; while (Q --) {
    int L, R; cin >> L >> R;
    int gap = (R - L + 1);
    i64 ans = 0;
    for (int mask = 0; mask < (1 << gap); mask ++) {
      i64 cur = 0;
      int d = -1, prev = -1, cnt = 0;
      bool works = true;
      for (int b = 0; b < gap; b ++) {
        if (mask >> b & 1) {
          cnt ++;
          cur = cur + a[b + L];
          if (prev == -1) prev = b;
          else if (d == -1) {
            d = b - prev;
            prev = b;
          } else if (d > b - prev) {
            works = false; break;
          }
        }
      }
      if (cnt == 3 && works) {
        ans = max(ans, cur);
      }
    }
    cout << ans << "\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(10);
  int Tests = 1; // cin >> Tests;
  while (Tests --) {
    Solve();
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 4091 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -