Submission #931751

# Submission time Handle Problem Language Result Execution time Memory
931751 2024-02-22T10:25:18 Z Aiperiii Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
8 / 100
3000 ms 32940 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
    vector <int> a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    while(q--){
        int l,r,x;
        cin>>l>>r>>x;
        vector <int> v;
        for(int i=l;i<=r;i++)v.pb(a[i]);
        bool ok=1;
        for(int i=0;i<v.size();i++){
            for(int j=0;j<v.size()-i-1;j++){
                if(v[j]>v[j+1]){
                    swap(v[j],v[j+1]);
                    if(x<v[j]+v[j+1]){
                        ok=0;break;
                    }
                }
            }
        }
        cout<<ok<<"\n";
    }
}
/*
5 2
3 5 1 8 2
1 3 6
2 5 3
 */

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:21:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
sortbooks.cpp:22:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   22 |             for(int j=0;j<v.size()-i-1;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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 464 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 27 ms 348 KB Output is correct
9 Correct 13 ms 348 KB Output is correct
10 Correct 23 ms 348 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 464 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 27 ms 348 KB Output is correct
9 Correct 13 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 152 ms 344 KB Output is correct
12 Correct 1096 ms 912 KB Output is correct
13 Correct 1046 ms 852 KB Output is correct
14 Correct 1826 ms 704 KB Output is correct
15 Correct 1713 ms 968 KB Output is correct
16 Execution timed out 3049 ms 604 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3032 ms 32940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3024 ms 2612 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 464 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 27 ms 348 KB Output is correct
9 Correct 13 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 152 ms 344 KB Output is correct
12 Correct 1096 ms 912 KB Output is correct
13 Correct 1046 ms 852 KB Output is correct
14 Correct 1826 ms 704 KB Output is correct
15 Correct 1713 ms 968 KB Output is correct
16 Execution timed out 3049 ms 604 KB Time limit exceeded
17 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 464 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 27 ms 348 KB Output is correct
9 Correct 13 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 152 ms 344 KB Output is correct
12 Correct 1096 ms 912 KB Output is correct
13 Correct 1046 ms 852 KB Output is correct
14 Correct 1826 ms 704 KB Output is correct
15 Correct 1713 ms 968 KB Output is correct
16 Execution timed out 3049 ms 604 KB Time limit exceeded
17 Halted 0 ms 0 KB -