Submission #249879

# Submission time Handle Problem Language Result Execution time Memory
249879 2020-07-16T08:27:40 Z TranGiaHuy1508 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
599 ms 8696 KB
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main(){
	int n, m; cin >> n >> m;
	vi w; w.assign(n, 0);
	for (int i=0; i<n; i++) cin >> w[i];
	for (int i=0; i<m; i++){
		int l, r, k;
		cin >> l >> r >> k; l--; r--;
		//Solve
		vii v; v.assign(r-l+1, ii());
		int res=0;
		for (int i=l; i<=r; i++) v[i-l]=ii(w[i], i);
		sort(v.begin(), v.end());
		for (int p=0; p<v.size(); p++){
			int a = v[p].first;
			int b = v[p].second;
			if (b==0) continue;
			int c = w[max_element(w.begin()+l, w.begin()+l+b)-w.begin()];
			if (a<c) res = max(res, a+c);
		}
		if (res<=k) cout << 1 << endl;
		else cout << 0 << endl;
		//cout << res << endl;
		//EndSolve
	}
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:20:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int p=0; p<v.size(); p++){
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 599 ms 8696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -