Submission #1040310

# Submission time Handle Problem Language Result Execution time Memory
1040310 2024-08-01T00:50:55 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
8 / 100
3000 ms 22988 KB
#include <bits/stdc++.h>
using namespace std;

int a[1000005];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= m; i++) {
        bool res = true;
        int l, r, w;
        cin >> l >> r >> w;

        vector<int> b(r - l + 1);
        for (int j = 0; j < r - l + 1; j++) {
            b[j] = a[l + j];
        }

        vector<int> c = b;
        sort(c.begin(), c.end());

        int temp = r - l + 1;
        for (int j = 0; j < temp & res; j++) {
            if (b[j] == c[j])
                continue;
            else {
                bool tempp = false;
                for (int k = j + 1; k < temp && res; k++) {
                    if (b[k] == c[j]) {
                        tempp = true;
                        for (int p = k; p > j; p--) {
                            if (b[p] + b[p - 1] <= w)
                                swap(b[p], b[p - 1]);
                            else {
                                res = false;
                                break;
                            }
                        }
                        break;
                    }
                }
                if (!tempp) {
                    res = false;
                    break;
                }
            }
        }

        if (res) cout << 1 << '\n';
        else cout << 0 << '\n';
    }
    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:26:27: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   26 |         for (int j = 0; j < temp & res; j++) {
      |                         ~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 392 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 532 KB Output is correct
7 Correct 5 ms 360 KB Output is correct
8 Correct 5 ms 352 KB Output is correct
9 Correct 4 ms 360 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 392 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 532 KB Output is correct
7 Correct 5 ms 360 KB Output is correct
8 Correct 5 ms 352 KB Output is correct
9 Correct 4 ms 360 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 124 ms 576 KB Output is correct
12 Correct 902 ms 860 KB Output is correct
13 Correct 1089 ms 656 KB Output is correct
14 Correct 1687 ms 696 KB Output is correct
15 Correct 1690 ms 648 KB Output is correct
16 Correct 1332 ms 900 KB Output is correct
17 Execution timed out 3044 ms 596 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 22988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 2300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 392 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 532 KB Output is correct
7 Correct 5 ms 360 KB Output is correct
8 Correct 5 ms 352 KB Output is correct
9 Correct 4 ms 360 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 124 ms 576 KB Output is correct
12 Correct 902 ms 860 KB Output is correct
13 Correct 1089 ms 656 KB Output is correct
14 Correct 1687 ms 696 KB Output is correct
15 Correct 1690 ms 648 KB Output is correct
16 Correct 1332 ms 900 KB Output is correct
17 Execution timed out 3044 ms 596 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 392 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 532 KB Output is correct
7 Correct 5 ms 360 KB Output is correct
8 Correct 5 ms 352 KB Output is correct
9 Correct 4 ms 360 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 124 ms 576 KB Output is correct
12 Correct 902 ms 860 KB Output is correct
13 Correct 1089 ms 656 KB Output is correct
14 Correct 1687 ms 696 KB Output is correct
15 Correct 1690 ms 648 KB Output is correct
16 Correct 1332 ms 900 KB Output is correct
17 Execution timed out 3044 ms 596 KB Time limit exceeded
18 Halted 0 ms 0 KB -