Submission #570192

# Submission time Handle Problem Language Result Execution time Memory
570192 2022-05-28T20:13:10 Z kamilamartinez Mountains (NOI20_mountains) C++14
70 / 100
2000 ms 7164 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <ll> unos;

int main() {
	ll n, i, cont=0, a, b, j, uc=0, cc=0;
	cin >> n;
	ll xd[n], ceros[n];
	bool lol=false, kk=false;
	for(i=0;i<n;i++) {
		cin >> xd[i];
		if(xd[i-1]>xd[i]) lol=true;
		if(xd[i]!=0 && xd[i]!=1) kk=true;
		if(xd[i]==1) uc++, unos.push_back(i);
		if(xd[i]==0) cc++;
		ceros[i]=cc;
	}
	if(lol==false) {
		cout << "0" << endl;
		return 0;
	}


	if(kk==false) {
		for(i=0;i<uc;i++) {
			if(unos[i]!=0 && unos[i]!=n-1) {
				cont+=ceros[unos[i]]*(cc-ceros[unos[i]]);
			}
			
		}
		cout << cont << endl;
		return 0;
	}
	
	for(i=1;i<n-1;i++) {
		a=0;
		b=0;
		for(j=0;j<i;j++) {
			if(xd[j]<xd[i]) a++;
		}
		for(j=i+1;j<n;j++) {
			if(xd[j]<xd[i]) b++;
		}
		cont+=a*b;
	}
	cout << cont << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 235 ms 4972 KB Output is correct
3 Correct 187 ms 4972 KB Output is correct
4 Correct 212 ms 4968 KB Output is correct
5 Correct 258 ms 4972 KB Output is correct
6 Correct 185 ms 5068 KB Output is correct
7 Correct 192 ms 4980 KB Output is correct
8 Correct 212 ms 4968 KB Output is correct
9 Correct 188 ms 4968 KB Output is correct
10 Correct 199 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 7076 KB Output is correct
2 Correct 49 ms 7096 KB Output is correct
3 Correct 43 ms 7088 KB Output is correct
4 Correct 47 ms 7140 KB Output is correct
5 Correct 49 ms 7124 KB Output is correct
6 Correct 47 ms 7164 KB Output is correct
7 Correct 48 ms 7104 KB Output is correct
8 Correct 43 ms 7112 KB Output is correct
9 Correct 42 ms 7088 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 7076 KB Output is correct
2 Correct 49 ms 7096 KB Output is correct
3 Correct 43 ms 7088 KB Output is correct
4 Correct 47 ms 7140 KB Output is correct
5 Correct 49 ms 7124 KB Output is correct
6 Correct 47 ms 7164 KB Output is correct
7 Correct 48 ms 7104 KB Output is correct
8 Correct 43 ms 7112 KB Output is correct
9 Correct 42 ms 7088 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2090 ms 5004 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 321 ms 428 KB Output is correct
12 Correct 298 ms 428 KB Output is correct
13 Correct 292 ms 340 KB Output is correct
14 Correct 327 ms 428 KB Output is correct
15 Correct 291 ms 428 KB Output is correct
16 Correct 312 ms 428 KB Output is correct
17 Correct 290 ms 428 KB Output is correct
18 Correct 294 ms 424 KB Output is correct
19 Correct 296 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 7076 KB Output is correct
2 Correct 49 ms 7096 KB Output is correct
3 Correct 43 ms 7088 KB Output is correct
4 Correct 47 ms 7140 KB Output is correct
5 Correct 49 ms 7124 KB Output is correct
6 Correct 47 ms 7164 KB Output is correct
7 Correct 48 ms 7104 KB Output is correct
8 Correct 43 ms 7112 KB Output is correct
9 Correct 42 ms 7088 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Execution timed out 2090 ms 5004 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 235 ms 4972 KB Output is correct
3 Correct 187 ms 4972 KB Output is correct
4 Correct 212 ms 4968 KB Output is correct
5 Correct 258 ms 4972 KB Output is correct
6 Correct 185 ms 5068 KB Output is correct
7 Correct 192 ms 4980 KB Output is correct
8 Correct 212 ms 4968 KB Output is correct
9 Correct 188 ms 4968 KB Output is correct
10 Correct 199 ms 4948 KB Output is correct
11 Correct 46 ms 7076 KB Output is correct
12 Correct 49 ms 7096 KB Output is correct
13 Correct 43 ms 7088 KB Output is correct
14 Correct 47 ms 7140 KB Output is correct
15 Correct 49 ms 7124 KB Output is correct
16 Correct 47 ms 7164 KB Output is correct
17 Correct 48 ms 7104 KB Output is correct
18 Correct 43 ms 7112 KB Output is correct
19 Correct 42 ms 7088 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Execution timed out 2090 ms 5004 KB Time limit exceeded
22 Halted 0 ms 0 KB -