Submission #238263

# Submission time Handle Problem Language Result Execution time Memory
238263 2020-06-10T15:08:51 Z Pbezz Pilot (NOI19_pilot) C++14
78 / 100
1000 ms 11116 KB
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for (ll i = 0; i < n; i++)

#define ll long long
#define INF 1e9+5
#define MAXN 1000005
#define MOD 1000000000007
#define pb push_back 
#define mp make_pair
typedef pair<ll,ll> pii;

	vector<ll>torre;
	vector<ll>plane;
	ll n;


bool sI(){

	for(ll i=1;i<n;i++){
	if(torre[i]<=torre[i-1])return false;

	}

	return true;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll q,y,k,ans,maxi=0;

	cin>>n>>q;

	loop(i,n){
	cin>>k;
	torre.pb(k);
	}

	loop(i,q){
	cin>>k;
	plane.pb(k);
	maxi=max(maxi,k);
	}

	if(sI()){//bs

	loop(i,q){

	y=plane[i];
	k=upper_bound(torre.begin(),torre.end(),y)-torre.begin();

	ans=(k*(k+1))/2;

	printf("%lld\n",ans);

}



	}else{

	ll dp[maxi+1];
	memset(dp,-1,sizeof(dp));


	loop(i,q){
	y=plane[i];

	if(dp[y]==-1){

		ans=0; ll cur=0;

		for(ll j=0;j<n;j++){

		while(j<n && torre[j]<=y){j++; cur++;}

		ans+=(cur*(cur+1))/2;

		cur=0; 
		}

		dp[y]=ans;
	}

	printf("%lld\n",dp[plane[i]]);

}


}
return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 8192 KB Output is correct
12 Correct 9 ms 8064 KB Output is correct
13 Correct 8 ms 7552 KB Output is correct
14 Correct 8 ms 8192 KB Output is correct
15 Correct 7 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 8192 KB Output is correct
12 Correct 9 ms 8064 KB Output is correct
13 Correct 8 ms 7552 KB Output is correct
14 Correct 8 ms 8192 KB Output is correct
15 Correct 7 ms 6272 KB Output is correct
16 Correct 8 ms 8192 KB Output is correct
17 Correct 8 ms 8064 KB Output is correct
18 Correct 10 ms 8064 KB Output is correct
19 Correct 9 ms 8192 KB Output is correct
20 Correct 8 ms 8064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 8192 KB Output is correct
12 Correct 9 ms 8064 KB Output is correct
13 Correct 8 ms 7552 KB Output is correct
14 Correct 8 ms 8192 KB Output is correct
15 Correct 7 ms 6272 KB Output is correct
16 Correct 8 ms 8192 KB Output is correct
17 Correct 8 ms 8064 KB Output is correct
18 Correct 10 ms 8064 KB Output is correct
19 Correct 9 ms 8192 KB Output is correct
20 Correct 8 ms 8064 KB Output is correct
21 Correct 9 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 10 ms 8192 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 10 ms 8192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 9592 KB Output is correct
2 Correct 22 ms 9720 KB Output is correct
3 Correct 20 ms 9592 KB Output is correct
4 Correct 20 ms 9592 KB Output is correct
5 Correct 19 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4080 KB Output is correct
2 Correct 50 ms 4080 KB Output is correct
3 Correct 47 ms 4080 KB Output is correct
4 Correct 51 ms 4208 KB Output is correct
5 Correct 50 ms 4076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4204 KB Output is correct
2 Correct 55 ms 4204 KB Output is correct
3 Correct 55 ms 4200 KB Output is correct
4 Correct 56 ms 4236 KB Output is correct
5 Correct 55 ms 4332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 19 ms 9592 KB Output is correct
12 Correct 22 ms 9720 KB Output is correct
13 Correct 20 ms 9592 KB Output is correct
14 Correct 20 ms 9592 KB Output is correct
15 Correct 19 ms 9592 KB Output is correct
16 Correct 16 ms 2168 KB Output is correct
17 Correct 19 ms 4600 KB Output is correct
18 Correct 18 ms 2808 KB Output is correct
19 Correct 17 ms 2044 KB Output is correct
20 Correct 20 ms 5752 KB Output is correct
21 Correct 16 ms 2680 KB Output is correct
22 Correct 19 ms 5880 KB Output is correct
23 Correct 18 ms 2044 KB Output is correct
24 Correct 17 ms 3192 KB Output is correct
25 Correct 16 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 8192 KB Output is correct
12 Correct 9 ms 8064 KB Output is correct
13 Correct 8 ms 7552 KB Output is correct
14 Correct 8 ms 8192 KB Output is correct
15 Correct 7 ms 6272 KB Output is correct
16 Correct 8 ms 8192 KB Output is correct
17 Correct 8 ms 8064 KB Output is correct
18 Correct 10 ms 8064 KB Output is correct
19 Correct 9 ms 8192 KB Output is correct
20 Correct 8 ms 8064 KB Output is correct
21 Correct 9 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 10 ms 8192 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 10 ms 8192 KB Output is correct
26 Correct 19 ms 9592 KB Output is correct
27 Correct 22 ms 9720 KB Output is correct
28 Correct 20 ms 9592 KB Output is correct
29 Correct 20 ms 9592 KB Output is correct
30 Correct 19 ms 9592 KB Output is correct
31 Correct 48 ms 4080 KB Output is correct
32 Correct 50 ms 4080 KB Output is correct
33 Correct 47 ms 4080 KB Output is correct
34 Correct 51 ms 4208 KB Output is correct
35 Correct 50 ms 4076 KB Output is correct
36 Correct 53 ms 4204 KB Output is correct
37 Correct 55 ms 4204 KB Output is correct
38 Correct 55 ms 4200 KB Output is correct
39 Correct 56 ms 4236 KB Output is correct
40 Correct 55 ms 4332 KB Output is correct
41 Correct 16 ms 2168 KB Output is correct
42 Correct 19 ms 4600 KB Output is correct
43 Correct 18 ms 2808 KB Output is correct
44 Correct 17 ms 2044 KB Output is correct
45 Correct 20 ms 5752 KB Output is correct
46 Correct 16 ms 2680 KB Output is correct
47 Correct 19 ms 5880 KB Output is correct
48 Correct 18 ms 2044 KB Output is correct
49 Correct 17 ms 3192 KB Output is correct
50 Correct 16 ms 2168 KB Output is correct
51 Execution timed out 1085 ms 11116 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 3328 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 7 ms 6016 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 8192 KB Output is correct
12 Correct 9 ms 8064 KB Output is correct
13 Correct 8 ms 7552 KB Output is correct
14 Correct 8 ms 8192 KB Output is correct
15 Correct 7 ms 6272 KB Output is correct
16 Correct 8 ms 8192 KB Output is correct
17 Correct 8 ms 8064 KB Output is correct
18 Correct 10 ms 8064 KB Output is correct
19 Correct 9 ms 8192 KB Output is correct
20 Correct 8 ms 8064 KB Output is correct
21 Correct 9 ms 8192 KB Output is correct
22 Correct 11 ms 8192 KB Output is correct
23 Correct 10 ms 8192 KB Output is correct
24 Correct 11 ms 8192 KB Output is correct
25 Correct 10 ms 8192 KB Output is correct
26 Correct 19 ms 9592 KB Output is correct
27 Correct 22 ms 9720 KB Output is correct
28 Correct 20 ms 9592 KB Output is correct
29 Correct 20 ms 9592 KB Output is correct
30 Correct 19 ms 9592 KB Output is correct
31 Correct 48 ms 4080 KB Output is correct
32 Correct 50 ms 4080 KB Output is correct
33 Correct 47 ms 4080 KB Output is correct
34 Correct 51 ms 4208 KB Output is correct
35 Correct 50 ms 4076 KB Output is correct
36 Correct 53 ms 4204 KB Output is correct
37 Correct 55 ms 4204 KB Output is correct
38 Correct 55 ms 4200 KB Output is correct
39 Correct 56 ms 4236 KB Output is correct
40 Correct 55 ms 4332 KB Output is correct
41 Correct 16 ms 2168 KB Output is correct
42 Correct 19 ms 4600 KB Output is correct
43 Correct 18 ms 2808 KB Output is correct
44 Correct 17 ms 2044 KB Output is correct
45 Correct 20 ms 5752 KB Output is correct
46 Correct 16 ms 2680 KB Output is correct
47 Correct 19 ms 5880 KB Output is correct
48 Correct 18 ms 2044 KB Output is correct
49 Correct 17 ms 3192 KB Output is correct
50 Correct 16 ms 2168 KB Output is correct
51 Execution timed out 1085 ms 11116 KB Time limit exceeded
52 Halted 0 ms 0 KB -