Submission #889805

# Submission time Handle Problem Language Result Execution time Memory
889805 2023-12-20T07:20:23 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 10408 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> weights(N);
    for (int i = 0; i < N; ++i) {
        cin >> weights[i];
    }
    for (int day = 0; day < M; ++day) {
        int l, r, k;
        cin >> l >> r >> k;
	    vector<int> subarray(weights.begin() + l - 1, weights.begin() + r);
        sort(subarray.begin(), subarray.end());
        bool possible = true;
        for (int i = 0; i < subarray.size() - 1; ++i) {
            if (subarray[i + 1] - subarray[i] > k) {
                possible = false;
                break;
            }
        }
        cout << (possible ? 1 : 0) << endl;
    }
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:18:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int i = 0; i < subarray.size() - 1; ++i) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3024 ms 10408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3068 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -