#include "pyramids.h"
#include <vector>
#include <numeric>
using namespace std;
vector<int> pyramidsA, pyramidsB;
vector<long long> prefixSumA, prefixSumB;
void init(vector<int> A, vector<int> B) {
    int N = A.size();
    pyramidsA = A;
    pyramidsB = B;
    prefixSumA.resize(N);
    prefixSumB.resize(N);
    prefixSumA[0] = A[0];
    prefixSumB[0] = B[0];
    for (int i = 1; i < N; ++i) {
        prefixSumA[i] = prefixSumA[i - 1] + A[i];
        prefixSumB[i] = prefixSumB[i - 1] + B[i];
    }
}
bool can_transform(int L, int R, int X, int Y) {
    long long sumA = prefixSumA[R] - (L > 0 ? prefixSumA[L - 1] : 0);
    long long sumB = prefixSumB[Y] - (X > 0 ? prefixSumB[X - 1] : 0);
    if (sumA != sumB) {
        return false;
    }
    // Check if it is possible to redistribute stones within the range
    int minA = *min_element(pyramidsA.begin() + L, pyramidsA.begin() + R + 1);
    int minB = *min_element(pyramidsB.begin() + X, pyramidsB.begin() + Y + 1);
    return minA <= minB;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |