Submission #471531

# Submission time Handle Problem Language Result Execution time Memory
471531 2021-09-09T16:32:18 Z jazzup Pilot (NOI19_pilot) C++11
89 / 100
1000 ms 67708 KB
/*input
6 3
1 3 2 4 1 2
2 3 4
*/
//NOI-SG 2019
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>

using namespace std;

long long ans[1000007];
pair<long long,long long> a[1000007];
set<long long> b;

int main(){
	long long n,q,y;
	set<long long>::iterator it;
	scanf("%lld%lld",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i].first);
		a[i].second=i+1;
	}

	sort(a,a+n,greater<pair<long long,long long> >());

	long long cur= (n*(n-1))/2 + n;

	long long idx=0;
	b.insert(0);
	b.insert(n+1);

	for(int i=1000000;i>0;i--){
		while(i<a[idx].first){
			it=b.lower_bound(a[idx].second);
			long long r=*it;

			it--;
			long long l=*it;
			
			long long diff=r-l-1;
			cur-=((diff*(diff-1))/2 + diff);

			diff=r-a[idx].second-1;
			cur+=((diff*(diff-1))/2 + diff);

			diff=a[idx].second-l-1;
			cur+=((diff*(diff-1))/2 + diff);

			b.insert(a[idx].second);

			idx++;

			if(idx==n){
				break;
			}
		}
		if(idx==n)break;
		ans[i]=cur;
	}

	for(int i=0;i<q;i++){
		scanf("%lld",&y);
		printf("%lld\n",ans[y]);
	}
	return 0;

}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%lld%lld",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
pilot.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%lld",&a[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
pilot.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   scanf("%lld",&y);
      |   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 5 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 7 ms 7696 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 5 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 7 ms 7696 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8012 KB Output is correct
19 Correct 5 ms 8012 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 5 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 7 ms 7696 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8012 KB Output is correct
19 Correct 5 ms 8012 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8184 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8176 KB Output is correct
25 Correct 6 ms 8108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 14532 KB Output is correct
2 Correct 65 ms 14508 KB Output is correct
3 Correct 69 ms 14348 KB Output is correct
4 Correct 62 ms 14056 KB Output is correct
5 Correct 68 ms 14156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 15336 KB Output is correct
2 Correct 80 ms 15360 KB Output is correct
3 Correct 96 ms 15120 KB Output is correct
4 Correct 83 ms 15472 KB Output is correct
5 Correct 77 ms 15172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 15492 KB Output is correct
2 Correct 84 ms 15264 KB Output is correct
3 Correct 86 ms 15060 KB Output is correct
4 Correct 85 ms 15612 KB Output is correct
5 Correct 84 ms 15272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 63 ms 14532 KB Output is correct
12 Correct 65 ms 14508 KB Output is correct
13 Correct 69 ms 14348 KB Output is correct
14 Correct 62 ms 14056 KB Output is correct
15 Correct 68 ms 14156 KB Output is correct
16 Correct 60 ms 14152 KB Output is correct
17 Correct 69 ms 14524 KB Output is correct
18 Correct 67 ms 14632 KB Output is correct
19 Correct 62 ms 14148 KB Output is correct
20 Correct 69 ms 14464 KB Output is correct
21 Correct 78 ms 14196 KB Output is correct
22 Correct 61 ms 14276 KB Output is correct
23 Correct 66 ms 14612 KB Output is correct
24 Correct 62 ms 14072 KB Output is correct
25 Correct 66 ms 14444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 5 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 7 ms 7696 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8012 KB Output is correct
19 Correct 5 ms 8012 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8184 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8176 KB Output is correct
25 Correct 6 ms 8108 KB Output is correct
26 Correct 63 ms 14532 KB Output is correct
27 Correct 65 ms 14508 KB Output is correct
28 Correct 69 ms 14348 KB Output is correct
29 Correct 62 ms 14056 KB Output is correct
30 Correct 68 ms 14156 KB Output is correct
31 Correct 81 ms 15336 KB Output is correct
32 Correct 80 ms 15360 KB Output is correct
33 Correct 96 ms 15120 KB Output is correct
34 Correct 83 ms 15472 KB Output is correct
35 Correct 77 ms 15172 KB Output is correct
36 Correct 84 ms 15492 KB Output is correct
37 Correct 84 ms 15264 KB Output is correct
38 Correct 86 ms 15060 KB Output is correct
39 Correct 85 ms 15612 KB Output is correct
40 Correct 84 ms 15272 KB Output is correct
41 Correct 60 ms 14152 KB Output is correct
42 Correct 69 ms 14524 KB Output is correct
43 Correct 67 ms 14632 KB Output is correct
44 Correct 62 ms 14148 KB Output is correct
45 Correct 69 ms 14464 KB Output is correct
46 Correct 78 ms 14196 KB Output is correct
47 Correct 61 ms 14276 KB Output is correct
48 Correct 66 ms 14612 KB Output is correct
49 Correct 62 ms 14072 KB Output is correct
50 Correct 66 ms 14444 KB Output is correct
51 Correct 110 ms 15272 KB Output is correct
52 Correct 110 ms 14904 KB Output is correct
53 Correct 133 ms 15392 KB Output is correct
54 Correct 138 ms 14880 KB Output is correct
55 Correct 102 ms 15328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8012 KB Output is correct
2 Correct 3 ms 5068 KB Output is correct
3 Correct 4 ms 6220 KB Output is correct
4 Correct 5 ms 8012 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 4 ms 4428 KB Output is correct
8 Correct 5 ms 8012 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 5 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 7 ms 7696 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8012 KB Output is correct
19 Correct 5 ms 8012 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8184 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8176 KB Output is correct
25 Correct 6 ms 8108 KB Output is correct
26 Correct 63 ms 14532 KB Output is correct
27 Correct 65 ms 14508 KB Output is correct
28 Correct 69 ms 14348 KB Output is correct
29 Correct 62 ms 14056 KB Output is correct
30 Correct 68 ms 14156 KB Output is correct
31 Correct 81 ms 15336 KB Output is correct
32 Correct 80 ms 15360 KB Output is correct
33 Correct 96 ms 15120 KB Output is correct
34 Correct 83 ms 15472 KB Output is correct
35 Correct 77 ms 15172 KB Output is correct
36 Correct 84 ms 15492 KB Output is correct
37 Correct 84 ms 15264 KB Output is correct
38 Correct 86 ms 15060 KB Output is correct
39 Correct 85 ms 15612 KB Output is correct
40 Correct 84 ms 15272 KB Output is correct
41 Correct 60 ms 14152 KB Output is correct
42 Correct 69 ms 14524 KB Output is correct
43 Correct 67 ms 14632 KB Output is correct
44 Correct 62 ms 14148 KB Output is correct
45 Correct 69 ms 14464 KB Output is correct
46 Correct 78 ms 14196 KB Output is correct
47 Correct 61 ms 14276 KB Output is correct
48 Correct 66 ms 14612 KB Output is correct
49 Correct 62 ms 14072 KB Output is correct
50 Correct 66 ms 14444 KB Output is correct
51 Correct 110 ms 15272 KB Output is correct
52 Correct 110 ms 14904 KB Output is correct
53 Correct 133 ms 15392 KB Output is correct
54 Correct 138 ms 14880 KB Output is correct
55 Correct 102 ms 15328 KB Output is correct
56 Execution timed out 1090 ms 67708 KB Time limit exceeded
57 Halted 0 ms 0 KB -