Submission #889749

# Submission time Handle Problem Language Result Execution time Memory
889749 2023-12-20T06:50:38 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
8 / 100
3000 ms 3676 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define forik(x) ll i = 1; i <= x; i++

// (a mod 1e9) / (b mod 1e9) = a * (b^1e9)

using namespace std;

ll a, b, c, d, e, t, n, m, k, p[200001];
vector <pair <ll, ll>> g;

//ll gcd (ll a, ll b){
//	while (a > 0 && b > 0){
//		if (a >= b){
//			a %= b;
//		}
//		else{
//			b %= a;
//		}
//	}
//	return a + b;
//}
//
//ll binpow (ll a, ll b){
//	a %= mod;
//	if (b == 0){
//		return 1;
//	}
//	if (b % 2 == 1){
//		return binpow (a, b - 1) % mod * a % mod;
//	}
//	else{
//		ll t = binpow (a, b / 2) % mod;
//		return t * t % mod;
//	}
//}

signed main (){
	//freopen (".in", "r", stdin);
	//freopen (".out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> p[i];
	}
	while (m--){
		cin >> a >> b >> c;
		g.clear();
		for (int i = a; i <= b; i++){
			g.pb ({p[i], i});
		}
		sort (all (g));
		a = 1;
		for (int i = 0; i < g.size() - 1; ++i){
			for (int y = i + 1; y < g.size(); y++){
				if (g[i].S > g[y].S && g[i].F + g[y].F > c){
					a = 0;
				}
			}
		}
		cout << a << '\n';
	}
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:65: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]
   65 |   for (int i = 0; i < g.size() - 1; ++i){
      |                   ~~^~~~~~~~~~~~~~
sortbooks.cpp:66:26: 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]
   66 |    for (int y = i + 1; y < g.size(); y++){
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 26 ms 348 KB Output is correct
8 Correct 26 ms 348 KB Output is correct
9 Correct 8 ms 476 KB Output is correct
10 Correct 31 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 26 ms 348 KB Output is correct
8 Correct 26 ms 348 KB Output is correct
9 Correct 8 ms 476 KB Output is correct
10 Correct 31 ms 344 KB Output is correct
11 Correct 742 ms 344 KB Output is correct
12 Execution timed out 3068 ms 684 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 3676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3080 ms 2268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 26 ms 348 KB Output is correct
8 Correct 26 ms 348 KB Output is correct
9 Correct 8 ms 476 KB Output is correct
10 Correct 31 ms 344 KB Output is correct
11 Correct 742 ms 344 KB Output is correct
12 Execution timed out 3068 ms 684 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 26 ms 348 KB Output is correct
8 Correct 26 ms 348 KB Output is correct
9 Correct 8 ms 476 KB Output is correct
10 Correct 31 ms 344 KB Output is correct
11 Correct 742 ms 344 KB Output is correct
12 Execution timed out 3068 ms 684 KB Time limit exceeded
13 Halted 0 ms 0 KB -