This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
using ll = long long;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector<int> A(N + 1);
map<int, vector<int>> mp;
for (int i = 1; i <= N; i++)
{
cin >> A[i];
mp[A[i]].push_back(i);
}
for (int i = 1; i <= N; i++)
{
auto it = upper_bound(mp[A[i]].begin(), mp[A[i]].end(), i);
if (it == mp[A[i]].end())
cout << A[i] << '\n';
else
{
for (int j = i; j < *it; j++)
cout << A[i] << '\n';
i = *it - 1;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |