Submission #557874

# Submission time Handle Problem Language Result Execution time Memory
557874 2022-05-06T08:20:40 Z FatihSolak W (RMI18_w) C++17
10 / 100
600 ms 2512 KB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
void solve(){
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 0;i<n;i++){
		int x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	int ans = 0;
	do{
		int cnt = 0;
		int last = -1;
		for(int i = 1;i<n;i++){
			if(v[i] == v[i-1])continue;
			int now = (v[i] > v[i-1]);
			if(now != last){
				if(last == -1 && now == 1){
					break;
				}
				cnt++;
				last = now;
			}
		}
		if(cnt == 4){
			ans++;
		}
		//if(cnt == 4){
		//	for(auto u:v){
		//		cout << u << " ";
		//	}
		//	cout << endl;
		//}
	}while(next_permutation(v.begin(),v.end()));
	cout << ans << endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	#ifdef Local
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	#ifdef Local
		cout << endl << fixed << setprecision(2) << 1000.0*clock()/CLOCKS_PER_SEC << " milliseconds.";
	#endif
}
# Verdict Execution time Memory Grader output
1 Correct 336 ms 308 KB Output is correct
2 Execution timed out 1093 ms 212 KB Time limit exceeded
3 Execution timed out 1099 ms 600 KB Time limit exceeded
4 Execution timed out 1084 ms 2512 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 212 KB Time limit exceeded
2 Execution timed out 1076 ms 212 KB Time limit exceeded
3 Execution timed out 1089 ms 468 KB Time limit exceeded
4 Execution timed out 1085 ms 984 KB Time limit exceeded
5 Execution timed out 1096 ms 1488 KB Time limit exceeded
6 Execution timed out 1054 ms 2512 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1079 ms 212 KB Time limit exceeded
3 Execution timed out 1079 ms 212 KB Time limit exceeded
4 Execution timed out 1080 ms 212 KB Time limit exceeded
5 Execution timed out 1077 ms 212 KB Time limit exceeded
6 Execution timed out 1095 ms 340 KB Time limit exceeded
7 Execution timed out 1089 ms 340 KB Time limit exceeded
8 Execution timed out 1097 ms 880 KB Time limit exceeded
9 Execution timed out 1096 ms 1396 KB Time limit exceeded
10 Execution timed out 1051 ms 2512 KB Time limit exceeded