# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
992777 | 2024-06-05T07:18:48 Z | n3rm1n | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 319 ms | 18004 KB |
#include<bits/stdc++.h> #define endl '\n' #define ll long long using namespace std; const long long MAXN = 1e6+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long n, m; long long a[MAXN], w; long long l, r, k; long long go[MAXN]; void read() { cin >> n >> m; for (long long i = 1; i <= n; ++ i) { cin >> a[i]; } } void solve5000() { for (long long i = 1; i <= m; ++ i) { cin >> l >> r >> k; vector < pair < long long, long long > > g; for (long long j = l; j <= r; ++ j) { g.push_back(make_pair(-a[j], j)); } sort(g.begin(), g.end()); long long cut = r+1, ok = 1; for (long long j = 0; j < g.size() && ok; ++ j) { for (long long id = g[j].second+1; id < cut && ok; ++ id) { if(a[id] - g[j].first <= k)continue; else { //cout << a[id] << " " << g[j].first << endl; ok = 0; } } cut = g[j].second; } cout << ok << endl; } } void solve13() { long long j = 1; for (long long i = 1; i <= n; ++ i) { j = max(j, i); while(j < n && a[j] <= a[j+1])j ++; go[i] = j; } for (long long i = 1; i <= m; ++ i) { cin >> l >> r >> k; if(go[l] < r)cout << 0 << endl; else cout << 1 << endl; } } int main() { speed(); read(); if(n <= 5000)solve5000(); else solve13(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 4 ms | 2396 KB | Output is correct |
7 | Correct | 4 ms | 2392 KB | Output is correct |
8 | Correct | 5 ms | 2392 KB | Output is correct |
9 | Correct | 3 ms | 2648 KB | Output is correct |
10 | Incorrect | 4 ms | 2396 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 4 ms | 2396 KB | Output is correct |
7 | Correct | 4 ms | 2392 KB | Output is correct |
8 | Correct | 5 ms | 2392 KB | Output is correct |
9 | Correct | 3 ms | 2648 KB | Output is correct |
10 | Incorrect | 4 ms | 2396 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 307 ms | 18004 KB | Output is correct |
2 | Correct | 301 ms | 18004 KB | Output is correct |
3 | Correct | 291 ms | 17872 KB | Output is correct |
4 | Correct | 319 ms | 17888 KB | Output is correct |
5 | Correct | 287 ms | 17932 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 34 ms | 6744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 4 ms | 2396 KB | Output is correct |
7 | Correct | 4 ms | 2392 KB | Output is correct |
8 | Correct | 5 ms | 2392 KB | Output is correct |
9 | Correct | 3 ms | 2648 KB | Output is correct |
10 | Incorrect | 4 ms | 2396 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 4 ms | 2396 KB | Output is correct |
7 | Correct | 4 ms | 2392 KB | Output is correct |
8 | Correct | 5 ms | 2392 KB | Output is correct |
9 | Correct | 3 ms | 2648 KB | Output is correct |
10 | Incorrect | 4 ms | 2396 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |