Submission #169072

# Submission time Handle Problem Language Result Execution time Memory
169072 2019-12-18T09:50:55 Z abil Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
8 / 100
3000 ms 8320 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);

int a[N], b[N];

main()
{
	int n, m; 
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n; i++){
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	int l, r, mood;
	while(m--){
		scanf("%d%d%d", &l, &r, &mood);
		int ok = 1, pos = l;
		while(1 && l != r){
			int mn = INF, posofval;
			for(int i = pos;i <= r; i++){
				if(a[i] < mn){
					mn = a[i];
					posofval = i;
				}
			}
			for(int i = posofval;i > pos; i--){
				if(a[i] + a[i - 1] > mood){
					ok = 0;
					break;
				}
				else{
					swap(a[i], a[i - 1]);
				}
			}
			pos++;
			if(!ok || pos == r){
				break;
			}
		}
		for(int i = l;i <= r; i++){
			a[i] = b[i];
		}
		printf("%d\n", ok);
	}
}

Compilation message

sortbooks.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &l, &r, &mood);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:31:18: warning: 'posofval' may be used uninitialized in this function [-Wmaybe-uninitialized]
    int mn = INF, posofval;
                  ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 26 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 29 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 26 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 29 ms 376 KB Output is correct
11 Correct 250 ms 528 KB Output is correct
12 Correct 2454 ms 524 KB Output is correct
13 Correct 2787 ms 732 KB Output is correct
14 Execution timed out 3052 ms 504 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3031 ms 8320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3050 ms 1144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 26 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 29 ms 376 KB Output is correct
11 Correct 250 ms 528 KB Output is correct
12 Correct 2454 ms 524 KB Output is correct
13 Correct 2787 ms 732 KB Output is correct
14 Execution timed out 3052 ms 504 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 26 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 29 ms 376 KB Output is correct
11 Correct 250 ms 528 KB Output is correct
12 Correct 2454 ms 524 KB Output is correct
13 Correct 2787 ms 732 KB Output is correct
14 Execution timed out 3052 ms 504 KB Time limit exceeded
15 Halted 0 ms 0 KB -