답안 #498179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498179 2021-12-24T14:10:00 Z OrazB Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
3000 ms 36500 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int
#define pii pair <long long, long long>
#define pb push_back
#define ff first
#define ss second
using namespace std;

ll n, m, l, r, k, mx, tr, a[N];
vector <pii> v;
vector <ll> b;

int main ()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int h = 1; h <= m; h++){
		cin >> l >> r >> k;
		tr = 0; v.clear(); b.clear();
		for (int i = l; i <= r; i++) b.pb(a[i]);
		for (int i = 0; i < b.size(); i++) v.pb({b[i], i});
		sort(v.begin(), v.end());
		for (int i = 0; i < v.size(); i++){
			if (v[i].ss != i){
				for (int j = i + 1; j <= v[i].ss; j++) mx = max(mx, b[j]);
				if (v[i].ff + mx > k){tr = 1; break;}						
				mx = 0;
			}
		}
		if (tr) cout << "0\n";
		else cout << "1\n";
	}
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int i = 0; i < b.size(); i++) v.pb({b[i], i});
      |                   ~~^~~~~~~~~~
sortbooks.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < v.size(); i++){
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3073 ms 36500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3047 ms 3756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -