Submission #471535

# Submission time Handle Problem Language Result Execution time Memory
471535 2021-09-09T16:47:22 Z jazzup Pilot (NOI19_pilot) C++11
89 / 100
1000 ms 58844 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<int,int> a[1000007];
set<int> b;

int main(){
	long long n,q,y;
	set<int>::iterator it;
	scanf("%lld%lld",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%d",&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("%d",&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 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 5 ms 8012 KB Output is correct
13 Correct 5 ms 8012 KB Output is correct
14 Correct 5 ms 7628 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 5 ms 8012 KB Output is correct
13 Correct 5 ms 8012 KB Output is correct
14 Correct 5 ms 7628 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8036 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8116 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 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 5 ms 8012 KB Output is correct
13 Correct 5 ms 8012 KB Output is correct
14 Correct 5 ms 7628 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8036 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8116 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 8092 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8180 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 6 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 13268 KB Output is correct
2 Correct 75 ms 13420 KB Output is correct
3 Correct 70 ms 13124 KB Output is correct
4 Correct 64 ms 12968 KB Output is correct
5 Correct 64 ms 13076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 14116 KB Output is correct
2 Correct 82 ms 14088 KB Output is correct
3 Correct 84 ms 13976 KB Output is correct
4 Correct 85 ms 14332 KB Output is correct
5 Correct 80 ms 13948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 14232 KB Output is correct
2 Correct 83 ms 14020 KB Output is correct
3 Correct 90 ms 13968 KB Output is correct
4 Correct 91 ms 14416 KB Output is correct
5 Correct 90 ms 14264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 KB Output is correct
9 Correct 2 ms 3148 KB Output is correct
10 Correct 5 ms 8012 KB Output is correct
11 Correct 88 ms 13268 KB Output is correct
12 Correct 75 ms 13420 KB Output is correct
13 Correct 70 ms 13124 KB Output is correct
14 Correct 64 ms 12968 KB Output is correct
15 Correct 64 ms 13076 KB Output is correct
16 Correct 72 ms 13072 KB Output is correct
17 Correct 74 ms 13480 KB Output is correct
18 Correct 69 ms 13416 KB Output is correct
19 Correct 67 ms 13016 KB Output is correct
20 Correct 72 ms 13316 KB Output is correct
21 Correct 63 ms 13056 KB Output is correct
22 Correct 70 ms 13096 KB Output is correct
23 Correct 71 ms 13476 KB Output is correct
24 Correct 70 ms 13068 KB Output is correct
25 Correct 67 ms 13252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 5 ms 8012 KB Output is correct
13 Correct 5 ms 8012 KB Output is correct
14 Correct 5 ms 7628 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8036 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8116 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 8092 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8180 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 6 ms 8140 KB Output is correct
26 Correct 88 ms 13268 KB Output is correct
27 Correct 75 ms 13420 KB Output is correct
28 Correct 70 ms 13124 KB Output is correct
29 Correct 64 ms 12968 KB Output is correct
30 Correct 64 ms 13076 KB Output is correct
31 Correct 83 ms 14116 KB Output is correct
32 Correct 82 ms 14088 KB Output is correct
33 Correct 84 ms 13976 KB Output is correct
34 Correct 85 ms 14332 KB Output is correct
35 Correct 80 ms 13948 KB Output is correct
36 Correct 87 ms 14232 KB Output is correct
37 Correct 83 ms 14020 KB Output is correct
38 Correct 90 ms 13968 KB Output is correct
39 Correct 91 ms 14416 KB Output is correct
40 Correct 90 ms 14264 KB Output is correct
41 Correct 72 ms 13072 KB Output is correct
42 Correct 74 ms 13480 KB Output is correct
43 Correct 69 ms 13416 KB Output is correct
44 Correct 67 ms 13016 KB Output is correct
45 Correct 72 ms 13316 KB Output is correct
46 Correct 63 ms 13056 KB Output is correct
47 Correct 70 ms 13096 KB Output is correct
48 Correct 71 ms 13476 KB Output is correct
49 Correct 70 ms 13068 KB Output is correct
50 Correct 67 ms 13252 KB Output is correct
51 Correct 103 ms 14076 KB Output is correct
52 Correct 105 ms 13816 KB Output is correct
53 Correct 101 ms 14148 KB Output is correct
54 Correct 106 ms 13804 KB Output is correct
55 Correct 102 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8028 KB Output is correct
2 Correct 4 ms 5068 KB Output is correct
3 Correct 5 ms 6172 KB Output is correct
4 Correct 6 ms 8012 KB Output is correct
5 Correct 4 ms 4044 KB Output is correct
6 Correct 5 ms 8012 KB Output is correct
7 Correct 3 ms 4428 KB Output is correct
8 Correct 5 ms 8116 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 5 ms 8012 KB Output is correct
13 Correct 5 ms 8012 KB Output is correct
14 Correct 5 ms 7628 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8036 KB Output is correct
17 Correct 6 ms 8012 KB Output is correct
18 Correct 5 ms 8116 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 8092 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8180 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 6 ms 8140 KB Output is correct
26 Correct 88 ms 13268 KB Output is correct
27 Correct 75 ms 13420 KB Output is correct
28 Correct 70 ms 13124 KB Output is correct
29 Correct 64 ms 12968 KB Output is correct
30 Correct 64 ms 13076 KB Output is correct
31 Correct 83 ms 14116 KB Output is correct
32 Correct 82 ms 14088 KB Output is correct
33 Correct 84 ms 13976 KB Output is correct
34 Correct 85 ms 14332 KB Output is correct
35 Correct 80 ms 13948 KB Output is correct
36 Correct 87 ms 14232 KB Output is correct
37 Correct 83 ms 14020 KB Output is correct
38 Correct 90 ms 13968 KB Output is correct
39 Correct 91 ms 14416 KB Output is correct
40 Correct 90 ms 14264 KB Output is correct
41 Correct 72 ms 13072 KB Output is correct
42 Correct 74 ms 13480 KB Output is correct
43 Correct 69 ms 13416 KB Output is correct
44 Correct 67 ms 13016 KB Output is correct
45 Correct 72 ms 13316 KB Output is correct
46 Correct 63 ms 13056 KB Output is correct
47 Correct 70 ms 13096 KB Output is correct
48 Correct 71 ms 13476 KB Output is correct
49 Correct 70 ms 13068 KB Output is correct
50 Correct 67 ms 13252 KB Output is correct
51 Correct 103 ms 14076 KB Output is correct
52 Correct 105 ms 13816 KB Output is correct
53 Correct 101 ms 14148 KB Output is correct
54 Correct 106 ms 13804 KB Output is correct
55 Correct 102 ms 14288 KB Output is correct
56 Execution timed out 1099 ms 58844 KB Time limit exceeded
57 Halted 0 ms 0 KB -