제출 #887296

#제출 시각아이디문제언어결과실행 시간메모리
887296votranngocvyHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
8 / 100
254 ms33220 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e6 + 5; int a[N],l[N],r[N],k[N],n,m; namespace sub1 { int b[N]; void solve() { for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) b[j] = a[j]; bool check = true; for (int j = l[i]; j < r[i]; j++) if (b[j] > b[j + 1]) { check = false; break; } while (!check) { bool found = false; for (int j = l[i]; j < r[i]; j++) if (b[j] > b[j + 1]) { if (b[j] + b[j + 1] <= k[i]) swap(b[j],b[j + 1]); else found = true; break; } if (found) break; check = true; for (int j = l[i]; j < r[i]; j++) if (b[j] > b[j + 1]) { check = false; break; } } cout << check << "\n"; } } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> l[i] >> r[i] >> k[i]; if (n <= 500 && m <= 500) sub1::solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...