Submission #910062

# Submission time Handle Problem Language Result Execution time Memory
910062 2024-01-17T20:19:13 Z vjudge1 Group Photo (JOI21_ho_t3) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	vector<int>pos(n+1);
	for(int i=0;i<n;i++){
		pos[h[i]]=i;
	}
	int swaps=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1-i;j++){
			if((h[j]+2*pos[h[j]])>(h[j+1]+2*pos[h[j+1]])){
				swap(pos[h[j]],pos[h[j+1]]);
				swaps++;
			}
		}
	}
	cout<<swaps<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -