Submission #574319

# Submission time Handle Problem Language Result Execution time Memory
574319 2022-06-08T10:21:41 Z Devigo Pilot (NOI19_pilot) C++14
78 / 100
1000 ms 4064 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair

const int siz = 0;
const int mod = 0;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n, q;
	cin >> n >> q;
	vector<long long> h(n);
	for(int i=0; i<n; i++) {
		cin >> h[i];
	}
	vector<long long> y(q);
	for(int i=0; i<q; i++) {
		cin >> y[i];
	}
	bool cnd = 1;
	for(int i=1; i<n; i++) {
		if(h[i] < h[i-1]) {
			cnd = 0; break;
		}
	}
	if(cnd) {
		for(int i=0; i<q; i++) {
			auto it = upper_bound(h.begin(),h.end(),y[i]);
			long long j = (it-h.begin());
            long long ans = ((j*(j+1))/2);
			cout << ans << "\n";
		}
		return 0;
	}
	vector<long long> ans;
	for(int i=0; i<q; i++) {
		long long x = y[i]; // x = 1e6
		long long sum = 0; long long s = 0;
		bool f = 0; 
		for(int j=0; j<n; j++) {
			if(h[j] > x) {
				long long k = max(0LL,j-s);
				sum += ((k*(k+1))/2);
				s = j+1; f = 1;
				continue;
			}
			f = 0;
		}
		if(f == 0) {
			long long k = n-s;
			sum += ((k*(k+1))/2);
		}
		ans.pb(sum);
	}
	for(long long j: ans) cout << j << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 980 KB Output is correct
2 Correct 10 ms 980 KB Output is correct
3 Correct 7 ms 980 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 9 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2644 KB Output is correct
2 Correct 40 ms 3964 KB Output is correct
3 Correct 31 ms 3836 KB Output is correct
4 Correct 29 ms 3916 KB Output is correct
5 Correct 28 ms 3772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2636 KB Output is correct
2 Correct 35 ms 3900 KB Output is correct
3 Correct 44 ms 4036 KB Output is correct
4 Correct 33 ms 4040 KB Output is correct
5 Correct 36 ms 4064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 10 ms 980 KB Output is correct
12 Correct 10 ms 980 KB Output is correct
13 Correct 7 ms 980 KB Output is correct
14 Correct 8 ms 980 KB Output is correct
15 Correct 9 ms 980 KB Output is correct
16 Correct 8 ms 980 KB Output is correct
17 Correct 11 ms 980 KB Output is correct
18 Correct 8 ms 1072 KB Output is correct
19 Correct 9 ms 980 KB Output is correct
20 Correct 8 ms 980 KB Output is correct
21 Correct 7 ms 980 KB Output is correct
22 Correct 8 ms 980 KB Output is correct
23 Correct 10 ms 1108 KB Output is correct
24 Correct 9 ms 980 KB Output is correct
25 Correct 11 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 10 ms 980 KB Output is correct
27 Correct 10 ms 980 KB Output is correct
28 Correct 7 ms 980 KB Output is correct
29 Correct 8 ms 980 KB Output is correct
30 Correct 9 ms 980 KB Output is correct
31 Correct 27 ms 2644 KB Output is correct
32 Correct 40 ms 3964 KB Output is correct
33 Correct 31 ms 3836 KB Output is correct
34 Correct 29 ms 3916 KB Output is correct
35 Correct 28 ms 3772 KB Output is correct
36 Correct 31 ms 2636 KB Output is correct
37 Correct 35 ms 3900 KB Output is correct
38 Correct 44 ms 4036 KB Output is correct
39 Correct 33 ms 4040 KB Output is correct
40 Correct 36 ms 4064 KB Output is correct
41 Correct 8 ms 980 KB Output is correct
42 Correct 11 ms 980 KB Output is correct
43 Correct 8 ms 1072 KB Output is correct
44 Correct 9 ms 980 KB Output is correct
45 Correct 8 ms 980 KB Output is correct
46 Correct 7 ms 980 KB Output is correct
47 Correct 8 ms 980 KB Output is correct
48 Correct 10 ms 1108 KB Output is correct
49 Correct 9 ms 980 KB Output is correct
50 Correct 11 ms 980 KB Output is correct
51 Execution timed out 1084 ms 3180 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 10 ms 980 KB Output is correct
27 Correct 10 ms 980 KB Output is correct
28 Correct 7 ms 980 KB Output is correct
29 Correct 8 ms 980 KB Output is correct
30 Correct 9 ms 980 KB Output is correct
31 Correct 27 ms 2644 KB Output is correct
32 Correct 40 ms 3964 KB Output is correct
33 Correct 31 ms 3836 KB Output is correct
34 Correct 29 ms 3916 KB Output is correct
35 Correct 28 ms 3772 KB Output is correct
36 Correct 31 ms 2636 KB Output is correct
37 Correct 35 ms 3900 KB Output is correct
38 Correct 44 ms 4036 KB Output is correct
39 Correct 33 ms 4040 KB Output is correct
40 Correct 36 ms 4064 KB Output is correct
41 Correct 8 ms 980 KB Output is correct
42 Correct 11 ms 980 KB Output is correct
43 Correct 8 ms 1072 KB Output is correct
44 Correct 9 ms 980 KB Output is correct
45 Correct 8 ms 980 KB Output is correct
46 Correct 7 ms 980 KB Output is correct
47 Correct 8 ms 980 KB Output is correct
48 Correct 10 ms 1108 KB Output is correct
49 Correct 9 ms 980 KB Output is correct
50 Correct 11 ms 980 KB Output is correct
51 Execution timed out 1084 ms 3180 KB Time limit exceeded
52 Halted 0 ms 0 KB -