Submission #471528

# Submission time Handle Problem Language Result Execution time Memory
471528 2021-09-09T16:29:39 Z jazzup Pilot (NOI19_pilot) C++14
40 / 100
85 ms 15512 KB
#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(){
	int n,q,y;
	set<int>::iterator it;
	scanf("%d%d",&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<int,int> >());

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

	int 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);
			int r=*it;

			it--;
			int l=*it;
			
			int 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("%d",&y);
		printf("%lld\n",ans[y]);
	}
	return 0;

}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d%d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~
pilot.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d",&a[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
pilot.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |   scanf("%d",&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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8096 KB Output is correct
14 Correct 5 ms 7580 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8096 KB Output is correct
14 Correct 5 ms 7580 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 5 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 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8096 KB Output is correct
14 Correct 5 ms 7580 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 5 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 5 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 7 ms 8100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 13892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 15188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 15512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 KB Output is correct
11 Incorrect 64 ms 13892 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8096 KB Output is correct
14 Correct 5 ms 7580 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 5 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 5 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 7 ms 8100 KB Output is correct
26 Incorrect 64 ms 13892 KB Output isn't correct
27 Halted 0 ms 0 KB -
# 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 8064 KB Output is correct
5 Correct 3 ms 4044 KB Output is correct
6 Correct 6 ms 8012 KB Output is correct
7 Correct 3 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 8096 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 8096 KB Output is correct
14 Correct 5 ms 7580 KB Output is correct
15 Correct 5 ms 8012 KB Output is correct
16 Correct 5 ms 8012 KB Output is correct
17 Correct 5 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 5 ms 8012 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 6 ms 8140 KB Output is correct
23 Correct 6 ms 8140 KB Output is correct
24 Correct 6 ms 8140 KB Output is correct
25 Correct 7 ms 8100 KB Output is correct
26 Incorrect 64 ms 13892 KB Output isn't correct
27 Halted 0 ms 0 KB -