Submission #1116335

# Submission time Handle Problem Language Result Execution time Memory
1116335 2024-11-21T14:10:24 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 29444 KB
// Problem: E - Hedgehog Daniyar and Algorithms
// Contest: Virtual Judge - Selection
// URL: https://vjudge.net/contest/673521#problem/E
// Memory Limit: 256 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>

#define int long long
#define ll long long;
#define rev reverse
#define ent '\n'
#define in insert
#define no "NO"
#define yes "YES"
#define sz size
#define pii pair<int,int>
#define pic pair<int,char>
#define pis pair<int,string>
#define pcc pair<char,char>
#define pci pair<char,int>
#define pcs pair<char,string>
#define pss pair<string,string>
#define psi pair<string,int>
#define psc pair<string,char>
#define pf push_front
#define pb push_back
#define F first
#define S second
#define con continue
#define ret return
#define all(x) x.begin(),x.end()
#define sayat_abi_crush_228 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int gcd(int a, int b){ while(a>0 and b>0){ if (a>b) swap(a,b); b%=a;}return a;}

struct triad {int a,b,c; triad(int x,int y,int z):a(x),b(y),c(z){}};

bool cmp(pii a, pii b){
    if (a.F==b.F){
        return a.S<b.S;
    }
    return a.F<b.F;
}

int binpow(int x,int n){
    if (n==0) return 1;
    if (n%2==1) return (binpow(x,n-1)*x);
    else {
        int a=(binpow(x,n/2));
        return (a*a);
    }
}



const int maxn=1e6+5,MOD=1e9+7, inf = 2147483647, linf = 9223372036854775807;

int n,m,a[maxn];

void sayat_abi_sigma_228(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++){
    	int l,r,k;
    	cin >> l >> r >> k;
    	vector<int>v,g;
    	for (int j = l; j <= r; j++){
    		v.pb(a[j]);
    		g.pb(a[j]);
    	}
    	sort(all(g));
    	for (int j = v.sz()-1; j > 0; j--){
    		if (v[j] < v[j-1] and v[j] + v[j-1] <= k) swap(v[j],v[j-1]);
    	}
    	int ans = 1;
    	for (int j = 0; j < v.sz(); j++){
    		if (v[j] != g[j]){
    			ans = 0;
    			break;
    		}
    	}
    	cout << ans << ent;
    }
}

signed main(){
    //freopen("slalom.in" , "r" , stdin);
    //freopen("slalom.out" , "w" , stdout);
    int t=1;
    sayat_abi_crush_228
    //cin>>t;
    for(int i = 1;i <= t;i++){
    //cout<<"Scenario #"<<i<<": ";
    sayat_abi_sigma_228();
    }
}

Compilation message

sortbooks.cpp: In function 'void sayat_abi_sigma_228()':
sortbooks.cpp:113:24: 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]
  113 |      for (int j = 0; j < v.sz(); j++){
      |                      ~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 29444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3060 ms 6132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -