답안 #942029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942029 2024-03-10T02:45:51 Z Tsagana Group Photo (JOI21_ho_t3) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mset multiset
#define F first
#define S second

using namespace std;

void solve ()
{
	int n; cin >> n;
	vector<int > v;
	int pos[5001];
	for (int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		v.pb(x);
		pos[x] = i;
	}
	int ans = 0;
	for (int i = 1; i < v.size(); i++)
	{
		if (v[i] != n && pos[v[i]] > pos[v[i]+1])
		{
			int l = pos[v[i]+1];
			int r = pos[v[i]];
			for (int j = r-1; j > l; j--)
			{
				pos[v[j-1]]++;
				ans++;
			}
			pos[v[i]] = pos[v[i]+1]+1;
		}
	}
	cout << ans;
}
signed main(){IOS solve(); return 0;}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:28:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i = 1; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Halted 0 ms 0 KB -