# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
942027 | Tsagana | Group Photo (JOI21_ho_t3) | C++14 | 1 ms | 488 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
cout << ans;
}
signed main(){IOS solve(); return 0;}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |