이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//-------------dilanyan------------\\
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//------------------KarginDefines--------------------\\
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
//-------------------KarginConstants------------------\\
const ll mod = 1000000007;
const ll inf = 1e18;
//-------------------KarginCode------------------------\\
const int N = 1000005;
int w[N];
void KarginSolve() {
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++) cin >> w[i];
if (n <= 5000 && m <= 5000) {
while (m--) {
int l, r, k;
cin >> l >> r >> k;
vector<int> a;
for (int i = l;i <= r;i++) a.pb(w[i]);
int ans = 1;
for (int i = 0;i < a.size() - 1;i++) {
for (int j = 0;j < a.size() - i - 1;j++) {
if (a[j] > a[j + 1]) {
if (a[j] + a[j + 1] <= k) {
swap(a[j], a[j + 1]);
}
else {
ans = 0;
break;
}
}
}
if (ans == 0) break;
}
cout << ans << '\n';
}
}
}
int main() {
//Usaco
Kargin;
int test = 1;
//cin >> test;
while (test--) {
KarginSolve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sortbooks.cpp:1:1: warning: multi-line comment [-Wcomment]
1 | //-------------dilanyan------------\\
| ^
sortbooks.cpp:8:1: warning: multi-line comment [-Wcomment]
8 | //------------------KarginDefines--------------------\\
| ^
sortbooks.cpp:22:1: warning: multi-line comment [-Wcomment]
22 | //-------------------KarginConstants------------------\\
| ^
sortbooks.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | //-------------------KarginCode------------------------\\
| ^
sortbooks.cpp: In function 'void KarginSolve()':
sortbooks.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0;i < a.size() - 1;i++) {
| ~~^~~~~~~~~~~~~~
sortbooks.cpp:44:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (int j = 0;j < a.size() - i - 1;j++) {
| ~~^~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |