답안 #928214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928214 2024-02-16T04:59:50 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 45276 KB
#include <bits/stdc++.h>
#define S second
#define F first
#define sz size()
#define int long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define yes "YES\n"
#define no "NO\n"
#define ent "\n"
#define give_me_more_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const int maxn = 1000, mod = 1e9 + 7;

void solve(){
  int n , q;
  cin >> n >> q;
  int a[n + 5];
  for(int i = 1;i <= n;i++) cin >> a[i];
  while(q--){
    int l , r , k;
    cin >> l >> r >> k;
    vector <int> ans;
    int ok = 1;
    vector <pair <int , int>> v;
    int cur = 0;
    for(int i = l;i <= r;i++){
      ans.pb(a[i]);
      v.pb({a[i] , cur});
      cur++;
    }
    sort(all(v));
    for(int i = 0;i < v.size();i++){
      int pos = 0;
      int mx = 0;
      if(v[i].S == 0) mx = 0;
      else mx = *max(ans.begin() , ans.begin() + v[i].S - 1);
      // cout<<mx<<ent;
      if(mx + v[i].F > k){
        ok = 0;break;
      }
      ans[v[i].S] = 0;
    }
    cout<<ok<<ent;
  }
}

signed main(){
  give_me_more_speed
  int t = 1;
  //cin>>t;
  for(int i = 1;i <= t;i++){
      solve();
  }
}

Compilation message

sortbooks.cpp: In function 'void solve()':
sortbooks.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0;i < v.size();i++){
      |                   ~~^~~~~~~~~~
sortbooks.cpp:36:11: warning: unused variable 'pos' [-Wunused-variable]
   36 |       int pos = 0;
      |           ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3010 ms 45276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3049 ms 6080 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -