text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int n, k, i, j, l, m, b[300001];
pair<int, int> a[300001];
int main() {
cin >> n;
for (i = 0; i < n; i++) {
cin >> k;
a[i].first = k;
a[i].second = i;
b[i] = 0;
}
sort(a, a + n);
k = 0;
for (i = 0; i < n; i++) {
if (k <= a[i].first) {
b[a[i].second] = a[i].first;
k = a[i].first + 1;
} else {
b[a[i].second] = k;
k++;
}
}
for (i = 0; i < n; i++) {
cout << b[i] << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int main() {
int n;
cin >> n;
vector<pair<int, int> > a(n);
vector<int> b(n), ans(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = i;
b[i] = a[i].first;
}
sort(a.begin(), a.end());
int cur = a[0].first;
ans[a[0].second] = cur;
for (int i = 1; i < n; i++) {
if (cur < a[i].first) {
cur = a[i].first;
ans[a[i].second] = cur;
} else if (cur == a[i].first) {
cur++;
ans[a[i].second] = cur;
} else {
cur++;
ans[a[i].second] = cur;
}
}
for (int i = 0; i < ans.size(); i++) {
cout << ans[i] << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x20202020;
const long long mod = 1000000007;
const double eps = 1e-9;
const double pi = 3.1415926535897932384626;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
long long res = 1;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long powmod(long long a, long long b, long long mod) {
long long res = 1;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 301000;
pair<int, int> p[N];
int a[N], n;
int main() {
scanf("%d", &n);
for (int i = 0; i < (int)n; i++)
scanf("%d", &a[i]), p[i] = make_pair(a[i], i);
sort(p, p + n);
for (int i = 1; i < (int)n; i++)
p[i].first = max(p[i - 1].first + 1, p[i].first);
for (int i = 0; i < (int)n; i++) a[p[i].second] = p[i].first;
for (int i = 0; i < (int)n; i++) printf("%d ", a[i]);
}
|
#include <bits/stdc++.h>
bool debug = false;
using namespace std;
int N;
vector<pair<int, int> > rating;
int ans[300005];
int main() {
scanf("%d", &N);
rating.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%d", &(rating[i].first));
(rating[i].second) = i;
}
sort(rating.begin(), rating.end());
if (debug) {
for (int i = 0; i < N; ++i)
cout << (rating[i].first) << "(" << (rating[i].second) << ") ";
cout << endl;
}
int nowPresent = 1;
for (int i = 0; i < N; ++i) {
if ((rating[i].first) > nowPresent) nowPresent = (rating[i].first);
if (debug) {
cout << " > " << (rating[i].second) << ": " << nowPresent << endl;
}
ans[(rating[i].second)] = nowPresent++;
}
for (int i = 0; i < N; ++i) printf("%d ", ans[i]);
}
|
#include <bits/stdc++.h>
struct nd {
int x;
int y;
} a[300050], s[300050];
int tp;
void merge(int p, int q, int r) {
int i, j, k;
tp = 0;
i = p;
j = q + 1;
while (j <= r) {
if (a[i].x > a[j].x) {
s[tp] = a[j];
tp++;
j++;
} else {
s[tp] = a[i];
i++;
tp++;
}
if (i > q) {
for (k = 0; k < tp; k++) {
a[p + k] = s[k];
}
tp = 0;
break;
}
}
if (i <= q) {
for (k = 0; q - k >= i; k++) {
a[r - k] = a[q - k];
}
for (k = 0; k < tp; k++) {
a[p + k] = s[k];
}
}
}
void mergesort(int s, int e) {
if (e - s > 1) {
mergesort(s, (s + e) / 2);
mergesort((s + e) / 2 + 1, e);
}
merge(s, (s + e) / 2, e);
}
int main() {
int i, j, g, iv, n;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &a[i].x);
a[i].y = i;
}
mergesort(1, n);
i = 1;
j = 2;
g = 0;
iv = a[1].x;
n++;
while (i < n) {
while (a[j].x <= iv + g && j < n) {
g++;
j++;
}
while (i != j) {
a[i].x = iv;
i++;
iv++;
}
iv = a[i].x;
j = i + 1;
g = 0;
}
for (i = 1; i < n; i++) {
s[a[i].y].x = a[i].x;
}
for (i = 1; i < n; i++) printf("%d ", s[i].x);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[300010];
long long n, mx;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
if (a[i].first <= mx) {
a[i].first = mx + 1;
mx++;
} else {
mx = a[i].first;
}
}
for (int i = 1; i <= n; i++) {
swap(a[i].first, a[i].second);
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
cout << a[i].second << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
struct Node {
int a, b;
} a[303000];
bool cmp(Node a, Node b) { return a.a < b.a; }
bool cmp1(Node a, Node b) { return a.b < b.b; }
int b[303000];
int main() {
int n;
cin >> n;
for (long long i = 1; i <= n; i++) cin >> a[i].a;
for (long long i = 1; i <= n; i++) a[i].b = i;
a[++n].a = 2000000000;
a[n].b = n;
sort(a + 1, a + 1 + n, cmp);
int tail = 0, head = 0;
for (long long i = 2; i <= n; i++) {
if (a[i].a == a[i - 1].a) b[++tail] = i;
if (a[i].a != a[i - 1].a) {
int k = min(tail - head, a[i].a - a[i - 1].a - 1);
for (long long j = 1; j <= k; j++) a[b[++head]].a = a[i - 1].a + j;
}
}
sort(a + 1, a + 1 + n, cmp1);
n--;
for (long long i = 1; i <= n - 1; i++) printf("%d ", a[i].a);
printf("%d\n", a[n].a);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool isSub(string str, string sub) {
int n, N;
N = str.size();
n = sub.size();
if (n == 0) return true;
if (N == 0 || N < n) return false;
if (str[0] == sub[0])
return isSub(str.substr(1, N - 1), sub.substr(1, n - 1));
else
return isSub(str.substr(1, N - 1), sub);
}
int nOf(string target, string str) {
int c = 0;
for (int i = str.find(target, 0); i != string::npos;
i = str.find(target, i + 1))
c++;
return c;
}
string lower(string s) {
string low_s = "";
for (int i = 0; i < s.size(); ++i) low_s += tolower(s[i]);
return low_s;
}
char NumtoChar(int digit) {
char ch[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
return ch[digit];
}
string NumToStr(int n) {
string s;
double i;
int digit;
for (i = 1 + floor((n > 0) ? log10(n) : 0); i > 0; i--) {
digit = (n - n % (int)(pow(10, i - 1))) / (int)(pow(10, i - 1)) % 10;
s += NumtoChar(digit);
}
return s;
}
int ChartoNum(char c) {
int num[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
if (c < 57)
return num[c - 48];
else
return num[c - 55];
}
string reverseStr(string s, int len) {
for (int i = 0; i < len / 2; i++) swap(s[i], s[len - i - 1]);
return s;
}
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
bool cmp2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
int n, MIN;
cin >> n;
vector<pair<int, int> > nums(n);
for (int i = 0; i < n; ++i) {
cin >> nums[i].first;
nums[i].second = i;
}
sort(nums.begin(), nums.end(), cmp);
MIN = nums[0].first;
for (int i = 0; i < n; ++i) {
if (nums[i].first <= MIN) {
nums[i].first = MIN;
MIN++;
} else {
MIN = nums[i].first + 1;
}
}
sort(nums.begin(), nums.end(), cmp2);
for (int i = 0; i < n; ++i) cout << nums[i].first << " ";
printf("\n");
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int maxn = 300005;
int n;
struct P {
int idx, val;
bool operator<(const P& a) const { return val < a.val; }
} a[maxn];
int ans[maxn];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i].val);
a[i].idx = i;
}
sort(a + 1, a + n + 1);
int cur = 1;
for (int i = 1; i <= n; i++) {
if (cur < a[i].val) cur = a[i].val;
ans[a[i].idx] = cur;
cur++;
}
for (int i = 1; i < n; i++) printf("%d ", ans[i]);
printf("%d\n", ans[n]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int range = 3 * (int)1e5;
pair<int, int> a[range + 5];
int b[range + 5], res[range + 5];
bool cmp(pair<int, int> a1, pair<int, int> a2) {
if (a1.first != a2.first)
return a1.first < a2.first;
else
return a1.second < a2.second;
}
int main() {
int n;
scanf("%d", &n);
int num;
for (int i = 1; i <= n; i++) {
scanf("%d", &num);
a[i] = make_pair(num, i);
b[i] = num;
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++)
res[a[i].second] = max(res[a[i - 1].second] + 1, b[a[i].second]);
for (int i = 1; i <= n; i++) printf("%d ", res[i]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct dulieu {
long int gt, tt;
};
long int n;
dulieu a[3 * 100005];
bool sx1(dulieu a, dulieu b) { return a.gt < b.gt; }
bool sx2(dulieu a, dulieu b) { return a.tt < b.tt; }
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].gt;
a[i].tt = i;
}
sort(a, a + n, sx1);
for (int i = 0; i < n; i++)
if (a[i].gt <= a[i - 1].gt) a[i].gt = a[i - 1].gt + 1;
sort(a, a + n, sx2);
for (int i = 0; i < n; i++) cout << a[i].gt << " ";
}
|
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;
pair<int, int> a[300010];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = (1); i <= (n); i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + 1 + n);
vector<pair<int, int> > res(1, {a[1].second, a[1].first});
for (int i = (2); i <= (n); i++) {
if (a[i].first <= a[i - 1].first) {
a[i].first = a[i - 1].first + 1;
}
res.emplace_back(a[i].second, a[i].first);
}
sort(res.begin(), res.end());
for (auto it : res) {
cout << it.second << ' ';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int arr1[300020];
pair<int, int> arr2[300020];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr1[i];
arr2[i].first = arr1[i];
arr2[i].second = i;
}
sort(arr2, arr2 + n);
for (int i = 1; i < n; i++) {
if (arr2[i].first <= arr2[i - 1].first) {
arr2[i].first = 1 + arr2[i - 1].first;
arr1[arr2[i].second] = arr2[i].first;
}
}
for (int i = 0; i < n; i++) cout << arr1[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, a;
vector<tuple<long long, long long>> vt;
vector<long long> vi;
scanf("%lld", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &a);
vt.push_back(make_tuple(a, i));
vi.push_back(a);
}
sort(vt.begin(), vt.end());
for (int i = 1; i < n; i++) {
long long x1 = get<0>(vt[i - 1]);
long long &x2 = get<0>(vt[i]);
long long y = get<1>(vt[i]);
if (x1 >= x2) {
x2 += (x1 - x2) + 1;
vi[y] = x2;
}
}
for (int i = 0; i < n; i++) printf("%lld ", vi[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 303030;
int N, ans[MAXN];
pair<int, int> vals[MAXN];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &vals[i].first);
vals[i].second = i;
}
sort(vals, vals + N);
for (int i = 0; i < N; i++) {
if (i > 0 && vals[i].first <= vals[i - 1].first) {
vals[i].first = vals[i - 1].first + 1;
}
ans[vals[i].second] = vals[i].first;
}
for (int i = 0; i < N; i++) {
printf("%d", ans[i]);
if (i < N - 1) {
printf(" ");
} else {
printf("\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 1e9 + 7;
const long double eps = 1e-9;
const int maxn = 111;
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<pair<long long, long long> > v;
for (long long i = 0; i < n; i++) {
long long x;
cin >> x;
v.push_back(make_pair(x, i));
}
sort((v).begin(), (v).end());
for (int i = 1; i < n; i++)
if (v[i].first <= v[i - 1].first) v[i].first = v[i - 1].first + 1;
for (int i = 0; i < n; i++) swap(v[i].first, v[i].second);
sort((v).begin(), (v).end());
for (int i = 0; i < n; i++) cout << v[i].second << ' ';
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n;
long long x[300001], y[300001];
long long cmp(long long i, long long j) { return x[i] < x[j]; }
int main() {
cin >> n;
for (long long i = 0; i < n; ++i) {
cin >> x[i];
y[i] = i;
}
sort(y, y + n, cmp);
long long p = x[y[0]] + 1;
for (long long i = 1; i < n; ++i) {
if (x[y[i]] <= p) {
x[y[i]] = p;
p += 1;
} else
p = x[y[i]] + 1;
}
for (long long i = 0; i < n; ++i) cout << x[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int next(int k) {
if (m.find(k) == m.end()) {
return k;
} else {
return m[k] = next(m[k]);
}
}
int main() {
int n, a, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a);
j = next(a);
printf("%d ", j);
m[j] = j + 1;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int long long num;
cin >> num;
vector<pair<int long long, int long long> > arr(num);
for (int i = 0; i < num; i++) {
cin >> arr[i].first;
arr[i].second = i;
}
sort(arr.begin(), arr.end());
for (int i = 0; i < num; i++) {
if (i == 0) {
continue;
}
if (arr[i].first > arr[i - 1].first) {
continue;
} else if (arr[i].first <= arr[i - 1].first) {
arr[i].first = arr[i - 1].first + 1;
}
}
sort(arr.begin(), arr.end(), sortbysec);
for (auto x : arr) {
cout << x.first << " ";
}
cout << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
bool sortBySec(pair<long long int, int>& a, pair<long long int, int>& b) {
return a.second < b.second;
}
void solve() {
long long int n;
cin >> n;
vector<pair<long long int, int>> arr(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i].first;
arr[i].second = i + 1;
}
sort((arr).begin(), (arr).end());
for (int i = 0; i < n - 1; ++i) {
if (arr[i].first == arr[i + 1].first) {
arr[i + 1].first++;
} else if (arr[i].first > arr[i + 1].first) {
arr[i + 1].first = arr[i].first + 1;
}
}
sort((arr).begin(), (arr).end(), sortBySec);
for (int i = 0; i < n; ++i) {
cout << arr[i].first << " ";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
solve();
}
|
#include <bits/stdc++.h>
using namespace std;
int sol[300010];
int main() {
int n;
int u;
scanf("%d", &n);
vector<pair<int, int> > arr;
for (int i = 0; i < (int)(n); ++i) {
scanf("%d", &u);
arr.push_back(make_pair(u, i));
}
sort(arr.begin(), arr.end());
int c = 0;
for (int i = 0; i < (int)(n); ++i) {
if (c < arr[i].first) {
sol[arr[i].second] = arr[i].first;
c = arr[i].first;
} else {
sol[arr[i].second] = c + 1;
c++;
}
}
for (int i = 0; i < (int)(n - 1); ++i) printf("%d ", sol[i]);
printf("%d\n", sol[n - 1]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, b;
cin >> N;
vector<pair<int, int> > V(N);
for (int i = 0; i < N; i++) {
cin >> V[i].first;
V[i].second = i;
}
sort(V.begin(), V.end());
b = V[0].first;
for (int i = 0; i < N; i++) {
if (V[i].first > b)
b = V[i].first + 1;
else {
V[i].first = b;
b++;
}
V[i] = make_pair(V[i].second, V[i].first);
}
sort(V.begin(), V.end());
cout << V[0].second;
for (int i = 1; i < N; i++) cout << " " << V[i].second;
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct st {
int idx, mn, p;
bool operator<(const st& a) const { return mn < a.mn; }
};
bool mycmp(const st& a, const st& b) { return a.idx < b.idx; }
int main() {
int N;
cin >> N;
st s;
vector<st> v;
for (int i = (0); i < (N); i++) {
int a;
cin >> a;
s.idx = i;
s.mn = a;
v.push_back(s);
}
sort(v.begin(), v.end());
int last = 0;
for (int i = (0); i < (N); i++) {
last = max(last + 1, v[i].mn);
v[i].p = last;
}
sort(v.begin(), v.end(), mycmp);
for (int i = (0); i < (N); i++) {
cout << v[i].p << " ";
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 5 + 3e5;
int sum[N];
int a[N], b[N];
long long ans[N];
map<int, int> mp;
vector<int> v[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, i, k = 0, j;
long long m, t = 0;
cin >> n;
for (i = 0; i < n; ++i) {
cin >> a[i];
b[i] = a[i];
}
sort(b, b + n);
for (i = 0; i < n; ++i) {
if (mp.find(b[i]) == mp.end()) {
mp[b[i]] = k;
v[k].push_back(b[i]);
++k;
}
}
for (i = 0; i < n; ++i) v[mp[a[i]]].push_back(i);
for (i = 0; i < k; ++i) {
m = v[i][0];
for (j = 1; j < v[i].size(); ++j) {
t = max(m, t);
ans[v[i][j]] = t;
++t;
}
}
cout << ans[0];
for (i = 1; i < n; ++i) cout << " " << ans[i];
}
|
#include <bits/stdc++.h>
struct cc {
long long int first;
int second;
};
bool io(cc x, cc y) { return x.first < y.first; }
bool oi(cc x, cc y) { return x.second < y.second; }
using namespace std;
int main() {
int n;
cin >> n;
cc a[n];
for (int i = 0; i <= n - 1; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a, a + n, io);
for (int i = 1; i <= n - 1; i++)
if (a[i].first <= a[i - 1].first) {
a[i].first = a[i - 1].first + 1;
}
sort(a, a + n, oi);
for (int i = 0; i <= n - 1; i++) cout << a[i].first << ' ';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
map<int, bool> mp;
vector<pair<int, int> > v;
int n, x;
cin >> n;
v.resize(n);
for (int i = 0; i < n; i++) scanf("%d", &v[i].first), v[i].second = i;
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
if (!mp[v[i].first]) {
mp[v[i].first] = true;
x = v[i].first + 1;
} else {
v[i].first = x;
x++;
mp[v[i].first] = true;
}
}
for (int i = 0; i < n; i++) swap(v[i].first, v[i].second);
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) printf("%d ", v[i].second);
}
|
#include <bits/stdc++.h>
struct person {
int x;
int y;
} a[300000];
int r[300000];
inline bool operator<(const person &a, const person &b) {
if (a.y != b.y) return a.y < b.y;
return a.x < b.x;
}
int main() {
int i, n, m = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
a[i].x = i;
scanf("%d", &a[i].y);
}
std::sort(a, a + n);
for (i = 0; i < n; i++) {
if (m < a[i].y)
r[a[i].x] = a[i].y;
else
r[a[i].x] = m;
m = r[a[i].x] + 1;
}
for (i = 0; i < n; i++) printf("%d ", r[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
int n = 0;
struct node {
int k;
int v;
int a;
} num[300010];
int cmp1(const void* x, const void* y) {
return ((struct node*)x)->a - ((struct node*)y)->a;
}
int cmp2(const void* x, const void* y) {
return ((struct node*)x)->k - ((struct node*)y)->k;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &num[i].a);
num[i].k = i;
}
qsort(num, n, sizeof(num[0]), cmp1);
num[0].v = num[0].a;
for (int i = 1; i < n; i++) {
if (num[i].a <= num[i - 1].v) {
num[i].v = num[i - 1].v + 1;
} else {
num[i].v = num[i].a;
}
}
qsort(num, n, sizeof(num[0]), cmp2);
printf("%d", num[0].v);
for (int i = 1; i < n; i++) {
printf(" %d", num[i].v);
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct name {
long long x;
long long y;
};
bool f(name x, name y) { return x.x < y.x; }
int main() {
ios::sync_with_stdio(0);
long long n;
cin >> n;
vector<name> a(n + 1);
vector<long long> ans(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i].x;
a[i].y = i;
}
sort(a.begin(), a.end(), f);
for (int i = 2; i <= n; i++)
if (a[i].x <= a[i - 1].x) a[i].x = a[i - 1].x + 1;
for (int i = 1; i <= n; i++) ans[a[i].y] = a[i].x;
for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, x;
vector<pair<int, int> > s, ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x;
s.push_back(make_pair(x, i));
}
sort(s.begin(), s.end());
ans.push_back(make_pair(s[0].second, s[0].first));
for (int i = 1; i < n; i++) {
if (s[i - 1].first >= s[i].first) s[i].first = s[i - 1].first + 1;
ans.push_back(make_pair(s[i].second, s[i].first));
}
sort(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++) {
cout << ans[i].second << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a[400100], b[400100], c[400100];
int i, n;
bool cmp(int i, int j) { return (a[i] < a[j]); }
int main() {
ios ::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
c[i] = i;
}
sort(c + 1, c + n + 1, cmp);
b[c[1]] = a[c[1]];
for (int i = 2; i <= n; i++) {
b[c[i]] = max(a[c[i]], b[c[i - 1]] + 1);
}
for (int i = 1; i <= n; i++) cout << b[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
long long binpow(long long a1, long long b1) {
if (b1 == 0) {
return 1;
}
if (b1 % 2 == 1) {
return binpow(a1, b1 - 1) * a1;
} else {
long long b = binpow(a1, b1 / 2);
return b * b;
}
}
long long gcd(long long a1, long long b1) {
if (b1 == 0)
return a1;
else
return gcd(b1, a1 % b1);
}
long long n;
vector<pair<long long, long long>> a;
long long ans[1000000];
int main() {
cin >> n;
long long a1;
for (int i = 0; i < n; i++) {
cin >> a1;
a.push_back(make_pair(a1, i + 1));
}
sort(a.begin(), a.end());
long long k = 0;
for (int i = 0; i < n; i++) {
if (k < a[i].first) {
k = a[i].first;
}
ans[a[i].second] = k;
k++;
}
for (int i = 1; i <= n; i++) {
cout << ans[i] << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int gcd(int big, int small) {
if (big % small == 0)
return small;
else
return gcd(small, big % small);
}
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
for (int i = 1; i < n; ++i) {
if (a[i].first <= a[i - 1].first) a[i].first = a[i - 1].first + 1;
}
vector<int> b(n);
for (int i = 0; i < n; ++i) {
b[a[i].second] = a[i].first;
}
for (int i = 0; i < n; ++i) cout << b[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline bool comp1(pair<int, int> a, pair<int, int> b) {
return a.second < b.second;
}
int main() {
int n, i, a, c;
vector<pair<int, int> > p;
vector<int> ans;
cin >> n;
ans.resize(n);
for (i = 0; i < n; i++) {
cin >> a;
p.push_back(make_pair(i, a));
}
sort(p.begin(), p.end(), comp1);
c = 1;
for (i = 0; i < n; i++) {
c = max(c, p[i].second);
ans[p[i].first] = c;
c++;
}
for (i = 0; i < n; i++) cout << ans[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct data {
int value;
int index;
};
struct data M[300000];
bool cmp1(struct data A, struct data B) { return A.value < B.value; }
bool cmp2(struct data A, struct data B) { return A.index < B.index; }
int main() {
int n;
while (scanf("%d", &n) == 1) {
int cur = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &M[i].value);
M[i].index = i;
}
sort(M, M + n, cmp1);
for (int i = 0; i < n; i++) {
if (cur <= M[i].value)
cur = M[i].value + 1;
else
M[i].value = cur, cur++;
}
sort(M, M + n, cmp2);
printf("%d", M[0].value);
for (int i = 1; i < n; i++) printf(" %d", M[i].value);
putchar('\n');
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, i;
cin >> n;
map<long long, long long> m;
vector<pair<long long, long long> > v;
for (i = 0; i < n; i++) {
long long temp;
cin >> temp;
v.push_back(make_pair(temp, i));
}
sort(v.begin(), v.end());
m[v[0].first] = 1;
for (i = 1; i < n; i++) {
if (m[v[i].first] == 0)
m[v[i].first] = 1;
else {
if (v[i].first <= v[i - 1].first) v[i].first = v[i - 1].first + 1;
m[v[i].first] = 1;
}
}
sort(v.begin(), v.end(), sortbysec);
for (i = 0; i < n; i++) {
cout << v[i].first << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e6;
int ans[MAX];
pair<int, int> x[MAX];
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
for (int i = 0; i < (int)(n); ++i) {
cin >> x[i].first;
x[i].second = i;
}
sort(x, x + n);
int cur = 0;
for (int i = 0; i < (int)(n); ++i) {
int nu = x[i].second;
int de = max(cur + 1, x[i].first);
ans[nu] = de;
cur = de;
}
for (int i = 0; i < (int)(n); ++i) cout << ans[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
void RI(int& x) {
x = 0;
char c = getchar();
while (!(c >= '0' && c <= '9' || c == '-')) c = getchar();
bool flag = 1;
if (c == '-') {
flag = 0;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
if (!flag) x = -x;
}
void RII(int& x, int& y) { RI(x), RI(y); }
void RIII(int& x, int& y, int& z) { RI(x), RI(y), RI(z); }
void RC(char& c) {
c = getchar();
while (c == ' ' || c == '\n') c = getchar();
}
char RC() {
char c = getchar();
while (c == ' ' || c == '\n') c = getchar();
return c;
}
const long long mod = 1e9 + 7;
const long long LINF = 1e18;
const int INF = 1e9;
const double EPS = 1e-8;
pair<int, int> a[300005];
bool cmp(pair<int, int> x, pair<int, int> y) { return x.second < y.second; }
int main() {
int n;
RI(n);
for (int i = 1; i <= n; i++) {
RI(a[i].first);
a[i].second = i;
}
sort(a + 1, a + n + 1);
for (int i = 2; i <= n; i++) {
a[i].first = max(a[i].first, a[i - 1].first + 1);
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++) {
cout << a[i].first << " ";
}
}
|
#include <bits/stdc++.h>
struct player {
int v, pos;
};
player arr[300100];
void qsort(int l, int r) {
int x = l, y = r, m = arr[l + rand() % (r - l)].v;
while (x <= y) {
while (arr[x].v < m) x++;
while (arr[y].v > m) y--;
if (x <= y) {
player tmp = arr[x];
arr[x] = arr[y];
arr[y] = tmp;
x++;
y--;
}
}
if (x < r) qsort(x, r);
if (l < y) qsort(l, y);
};
int output[300100];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i].v);
arr[i].pos = i;
}
if (n > 1) qsort(0, n - 1);
int l = 0, r = 0;
int next = arr[0].v;
while (l < n) {
while (r < n && (l == r || arr[r].v == arr[r - 1].v)) {
r++;
}
next = ((next) > (arr[l].v) ? (next) : (arr[l].v));
while (l < r && (r == n || next < arr[r].v)) {
output[arr[l].pos] = next;
next++;
l++;
}
r++;
}
for (int i = 0; i < n; i++) printf("%d ", output[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
pair<long long, long long> arr[n];
for (int i = 0; i < n; i++) {
int a;
cin >> a;
arr[i] = make_pair(a, i);
}
sort(arr, arr + n);
int last = (int)arr[0].first;
for (int i = 1; i <= n - 1; i++) {
if (arr[i].first <= last) arr[i].first = ++last;
last = max(last, (int)arr[i].first);
}
int out[n];
for (auto a : arr) out[a.second] = a.first;
for (auto o : out) cout << o << " ";
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
pair<long long, long long> p[300010];
inline void input() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p[i].first;
p[i].second = i;
}
sort(p, p + n);
int cnt = p[0].first, o = 0;
for (int i = 1; i < n; i++) {
if (p[i].first == cnt) {
o++;
p[i].first += o;
} else {
if (p[i].first <= p[i - 1].first) p[i].first = p[i - 1].first + 1;
cnt = p[i].first;
o = 0;
}
}
for (int i = 0; i < n; i++) swap(p[i].first, p[i].second);
sort(p, p + n);
for (int i = 0; i < n; i++) cout << p[i].second << " ";
}
int main() { input(); }
|
#include <bits/stdc++.h>
using namespace std;
int n, ok, pos;
bool direction;
vector<pair<int, int> > a;
vector<int> ans;
int main() {
cin >> n;
for (int i = 0, aux; i < n; i++)
cin >> aux, a.push_back(make_pair(aux, i)), ans.push_back(aux);
sort(a.begin(), a.end());
int act = a[0].first;
for (int i = 0; i < n; i++, act++) {
if (act < a[i].first) act = a[i].first;
if (act >= a[i].first) ans[a[i].second] = act;
}
for (int i = 0; i < n; i++) cout << (i ? " " : "") << ans[i];
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ans[300005];
struct node {
int pos, val;
} e[300005];
int cmp(const node &a, const node &b) { return a.val < b.val; }
int main() {
int i, n;
while (scanf("%d", &n) != EOF) {
for (i = 1; i <= n; i++) {
scanf("%d", &e[i].val);
e[i].pos = i;
}
sort(e + 1, e + n + 1, cmp);
ans[e[1].pos] = e[1].val;
for (i = 2; i <= n; i++) {
if (e[i].val == e[i - 1].val)
ans[e[i].pos] = ans[e[i - 1].pos] + 1;
else
ans[e[i].pos] = max(e[i].val, ans[e[i - 1].pos] + 1);
}
printf("%d", ans[1]);
for (i = 2; i <= n; i++) printf(" %d", ans[i]);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct par {
int val;
int ind;
};
bool cmp(par A, par B) { return A.val < B.val; }
int n;
par a[300010];
int b[300010];
int cur;
int main() {
cur = 1;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i].val);
a[i].ind = i;
}
sort(a, a + n, cmp);
for (int i = 0; i < n; i++) {
if (a[i].val > cur)
b[a[i].ind] = a[i].val, cur = a[i].val + 1;
else
b[a[i].ind] = cur, cur++;
}
for (int i = 0; i < n; i++) printf("%d ", b[i]);
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e5 + 5;
map<int, int> vis;
struct node {
int x, y;
} a[MaxN];
bool cmp1(node c, node d) { return c.x < d.x; }
bool cmp2(node c, node d) { return c.y < d.y; }
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i].x);
a[i].y = i;
vis[a[i].x]++;
}
sort(a + 1, a + 1 + n, cmp1);
for (int i = 1; i <= n; i++) {
if (vis[a[i].x] && a[i].x <= a[i - 1].x) {
a[i].x = a[i - 1].x + 1;
vis[a[i].x]++;
}
}
sort(a + 1, a + 1 + n, cmp2);
for (int i = 1; i <= n; i++) printf("%d ", a[i].x);
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
int key;
int id;
} a[300010], b[300010];
bool cmp1(const node &a, const node &b) { return a.key < b.key; }
bool cmp2(const node a, const node b) { return a.id < b.id; }
int main(int argc, char *argv[]) {
int num, i;
scanf("%d", &num);
for (i = 0; i < num; ++i) {
scanf("%d", &a[i].key);
a[i].id = i;
}
sort(a, a + num, cmp1);
b[0] = a[0];
for (i = 1; i < num; ++i) {
b[i].key = max(b[i - 1].key + 1, a[i].key);
b[i].id = a[i].id;
}
sort(b, b + num, cmp2);
printf("%d", b[0].key);
for (i = 1; i < num; ++i) {
printf(" %d", b[i].key);
}
return 0;
}
|
#include <bits/stdc++.h>
const int con = 300010;
int q[con], q1[con], v[con];
void sort(int l, int r) {
int l1 = l, r1 = (l + r) / 2 + 1, m = (l + r) / 2 + 1, cur = l;
if (l == r) return;
sort(l, m - 1);
sort(m, r);
while (l1 < m && r1 <= r) {
if (v[q[l1]] < v[q[r1]]) {
q1[cur] = q[l1];
l1++;
} else {
q1[cur] = q[r1];
r1++;
}
cur++;
}
if (l1 == m)
while (cur <= r) {
q1[cur] = q[r1];
r1++;
cur++;
}
else
while (cur <= r) {
q1[cur] = q[l1];
l1++;
cur++;
}
for (m = l; m <= r; m++) q[m] = q1[m];
}
void solve(int n) {
int i;
for (i = 0; i < n; i++) {
scanf("%d", &v[i]);
q[i] = i;
}
sort(0, n - 1);
for (i = 0; i < n - 1; i++)
if (v[q[i + 1]] <= v[q[i]]) v[q[i + 1]] = v[q[i]] + 1;
for (i = 0; i < n; i++) printf("%d ", v[i]);
printf("\n");
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
solve(n);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, t;
cin >> n;
map<long long int, long long int> mp;
vector<pair<long long int, long long int> > a, ans;
for (int i = 0; i < n; i++) {
cin >> t;
a.push_back({t, i});
}
a.push_back({1e9 + 5, 1e9 + 5});
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
while (mp[a[i].first] != 0) {
a[i].first++;
}
mp[a[i].first] = 1;
a[i + 1].first = max(a[i + 1].first, a[i].first + 1);
ans.push_back({a[i].second, a[i].first});
}
sort(ans.begin(), ans.end());
for (int i = 0; i < n; i++) cout << ans[i].second << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
long a[n], b[n], v;
for (int i = 0; i < n; i++) {
scanf("%ld", &a[i]);
b[i] = a[i];
}
sort(a, a + n);
map<long, long> m;
m[a[0]] = a[0];
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
m[a[i]] = m[a[i]] + 1;
v = m[a[i]];
m[v] = -1;
} else {
if (m[a[i]] == 0)
m[a[i]] = a[i];
else if (m[a[i]] == -1) {
m[a[i]] = v + 1;
m[v + 1] = -1;
v++;
}
}
}
for (int i = 0; i < n; i++) {
printf("%ld ", m[b[i]]);
m[b[i]]--;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
pair<int, int> v[MAXN];
int ans[MAXN];
int main() {
ios::sync_with_stdio(false);
;
int n;
cin >> n;
for (int i = 0; i < (n); ++i) {
cin >> v[i].first;
v[i].second = i;
}
sort(v, v + n);
int rmin = 1;
for (int i = 0; i < (n); ++i) {
int x = max(rmin, v[i].first);
ans[v[i].second] = x;
rmin = x + 1;
}
for (int i = 0; i < (n); ++i) cout << ans[i] << " ";
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<pair<long long, long long> > input;
vector<pair<long long, long long> > ret;
ret.assign(n, pair<long long, long long>(0, 0));
input.assign(n, pair<long long, long long>(0, 0));
long long int curr = -1;
for (long long int i = 0; i < n; i++) {
cin >> input[i].first;
input[i].second = i;
}
sort(input.begin(), input.end());
for (long long i = 0; i < n; i++) {
ret[i].second = max(input[i].first, curr + 1);
curr = ret[i].second;
ret[i].first = input[i].second;
}
sort(ret.begin(), ret.end());
for (long long i = 0; i < n; i++) {
cout << ret[i].second << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int N;
pair<int, int> arr[MAXN];
int ans[MAXN];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &arr[i].first);
arr[i].second = i;
}
sort(arr, arr + N);
int cur = arr[0].first;
for (int i = 1; i < N; i++) {
if (++cur < arr[i].first) {
cur = arr[i].first;
} else {
arr[i].first = cur;
}
}
for (int i = 0; i < N; i++) {
ans[arr[i].second] = arr[i].first;
}
for (int i = 0; i < N; i++) {
printf("%d ", ans[i]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e9 + 1;
unsigned long long n, m, i, j, k = 0, cou = 0, F;
bool compare_first(pair<unsigned long long, long long> a,
pair<unsigned long long, long long> b) {
return (a.first < b.first);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
vector<pair<unsigned long long, long long> > v;
unsigned long long a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
v.push_back(make_pair(a[i], i));
}
sort(v.begin(), v.end());
k = 0;
for (i = 0; i < v.size(); i++) {
if (v[i].first > k) {
k = v[i].first;
} else {
a[v[i].second] = k + 1;
k++;
}
}
for (i = 0; i < n; i++) {
cout << a[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[303030], o[303030], m;
pair<int, int> p[303030];
int main() {
ios::sync_with_stdio(0);
cin.tie();
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) p[i] = {a[i], i};
sort(p, p + n);
for (int i = 0; i < n; i++) {
auto [a, b] = p[i];
o[b] = max(a, m + 1);
m = o[b];
}
for (int i = 0; i < n; i++) cout << o[i] << ' ';
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mabs(const T &a) {
return a < 0 ? -a : a;
}
void run() {
int n;
pair<int, int> A[300300];
cin >> n;
for (int i = (0), ei = (n); i < ei; i++) {
scanf("%d", &A[i].first);
A[i].second = i;
}
sort(A, A + n);
int curr = 0;
int Res[300300];
for (int i = (0), ei = (n); i < ei; i++) {
curr = max(curr, A[i].first);
Res[A[i].second] = curr;
++curr;
}
for (int i = (0), ei = (n); i < ei; i++) printf("%d ", Res[i]);
puts("");
}
int main() {
run();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
scanf("%d", &N);
pair<int, int> *P = new pair<int, int>[N];
int *A = new int[N];
for (int i = 0; i < N; i++) {
scanf("%d", &P[i].first);
P[i].second = i;
}
sort(P, P + N);
int p = 0;
for (int i = 0; i < N; i++) {
if (P[i].first < ++p) P[i].first = p;
A[P[i].second] = p = P[i].first;
}
for (int i = 0; i < N; i++) {
if (i != 0) putchar(' ');
printf("%d", A[i]);
}
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool secondAsc(const pair<int, int>& a, const pair<int, int>& b) {
if (a.second <= b.second) {
return true;
}
return false;
}
int main() {
int n;
while (cin >> n) {
vector<pair<int, int> > a(n, pair<int, int>());
for (int i = 0; i < n; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
int p = a[0].first;
for (int i = 0; i < n; ++i) {
if (p < a[i].first) {
p = a[i].first;
}
a[i].first = p++;
}
sort(a.begin(), a.end(), secondAsc);
bool first = true;
for (int i = 0; i < n; ++i) {
if (first) {
first = false;
} else {
cout << " ";
}
cout << a[i].first;
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, a;
vector<tuple<long long, long long>> vt;
vector<long long> vi;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
vt.push_back(make_tuple(a, i));
vi.push_back(a);
}
sort(vt.begin(), vt.end());
for (int i = 1; i < n; i++) {
long long x1 = get<0>(vt[i - 1]);
long long &x2 = get<0>(vt[i]);
long long y = get<1>(vt[i]);
if (x1 >= x2) {
x2 += (x1 - x2) + 1;
vi[y] = x2;
}
}
for (int i = 0; i < n; i++) cout << vi[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
pair<int, int> data[300005];
int res[300005];
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
int n, tmp, min = 0;
scanf("%d", &n);
for (int i = (0); i <= (n - 1); i++) {
scanf("%d", &tmp);
data[i] = make_pair(i, tmp);
}
sort(data, data + n, cmp);
for (int i = (0); i <= (n - 1); i++) {
if (data[i].second > min)
min = res[data[i].first] = data[i].second;
else
min = res[data[i].first] = min + 1;
}
for (int i = (0); i <= (n - 1); i++)
printf("%d%c", res[i], i == n - 1 ? '\n' : ' ');
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[3 * 100000 + 5], r[3 * 100000 + 5];
bool cmp(int x, int y) { return a[x] < a[y]; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
r[i] = i;
}
sort(r + 1, r + n + 1, cmp);
for (int i = 2; i <= n; i++) {
if (a[r[i]] <= a[r[i - 1]]) a[r[i]] = a[r[i - 1]] + 1;
}
printf("%d", a[1]);
for (int i = 2; i <= n; i++) printf(" %d", a[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
bool indexsort(const pair<int, int>& p1, const pair<int, int>& p2) {
return p1.first < p2.first;
}
bool valuesort(const pair<int, int>& p1, const pair<int, int>& p2) {
return p1.second < p2.second;
}
int main() {
int n;
cin >> n;
int input;
vector<pair<int, int> > myvector;
for (int i = 1; i < n + 1; i++) {
cin >> input;
myvector.push_back(pair<int, int>(i, input));
}
sort(myvector.begin(), myvector.end(), valuesort);
for (int j = 1; j < n; j++) {
if (myvector[j].second <= myvector[j - 1].second) {
myvector[j].second = myvector[j - 1].second + 1;
}
}
sort(myvector.begin(), myvector.end(), indexsort);
for (int i = 0; i < n; i++) {
cout << myvector[i].second << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct present {
int pos;
int val;
} a[300009];
bool cmpVal(const present &a, const present &b) { return a.val < b.val; }
bool cmpPos(const present &a, const present &b) { return a.pos < b.pos; }
int main(int argc, char *argv[]) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
a[i].pos = i;
scanf("%d", &a[i].val);
}
sort(a, a + n, cmpVal);
int value = 0;
for (int i = 0; i < n; i++) {
if (a[i].val > value)
value = a[i].val;
else
a[i].val = value;
value++;
}
sort(a, a + n, cmpPos);
for (int i = 0; i < n; i++) {
if (i == 0)
printf("%d", a[i].val);
else
printf(" %d", a[i].val);
}
printf("\n");
return EXIT_SUCCESS;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
struct yapi {
int x, ind;
} ar[323123];
bool cmp1(yapi a, yapi b) { return a.x < b.x; }
bool cmp2(yapi a, yapi b) { return a.ind < b.ind; }
int main() {
scanf(" %d", &n);
for (int i = 0; i < n; i++) {
scanf(" %d", &ar[i].x);
ar[i].ind = i;
}
sort(ar, ar + n, cmp1);
for (int i = 0; i < n; i++) {
if (i && ar[i].x <= ar[i - 1].x) ar[i].x = ar[i - 1].x + 1;
}
sort(ar, ar + n, cmp2);
for (int i = 0; i < n; i++) {
printf("%d ", ar[i].x);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
long int n;
cin >> n;
vector<pair<long long int, long int> > v(n);
vector<long long int> x(n);
for (long int i = 0; i < n; ++i) {
long long int a;
cin >> a;
v[i] = make_pair(a, i);
}
sort(v.begin(), v.end());
for (long int i = 1; i < n; ++i) {
if (v[i].first <= v[i - 1].first) v[i].first = v[i - 1].first + 1;
}
for (long int i = 0; i < n; ++i) {
x[v[i].second] = v[i].first;
}
cout << x[0];
for (long int i = 1; i < n; ++i) {
cout << " " << x[i];
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
struct DATA {
int index, value, rate;
};
int n, p = 1;
DATA x[500000];
int max(int x, int y) { return x > y ? x : y; }
bool cmp_index(DATA l, DATA r) { return l.index < r.index; }
bool cmp_value(DATA l, DATA r) { return l.value < r.value; }
int main() {
int i;
scanf("%d", &n);
for (i = 0; i < n; i++) {
x[i].index = i;
scanf("%d", &x[i].value);
}
std::sort(x, x + n, cmp_value);
for (i = 0; i < n; i++) {
x[i].rate = max(p, x[i].value);
p = x[i].rate + 1;
}
std::sort(x, x + n, cmp_index);
for (i = 0; i < n; i++) printf("%d ", x[i].rate);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct pnt {
long long a, num;
};
bool cmp(pnt a, pnt b) { return a.a < b.a || (a.a == b.a && a.num < b.num); }
bool cmp2(pnt a, pnt b) { return a.num < b.num; }
pnt a[301000];
int main() {
int i, n;
long long uk = 0;
cin >> n;
for (i = 0; i < n; ++i) {
cin >> a[i].a;
a[i].num = i;
}
sort(a, a + n, cmp);
for (i = 0; i < n; ++i) {
if (a[i].a > uk)
uk = a[i].a;
else
++uk;
a[i].a = uk;
}
sort(a, a + n, cmp2);
for (i = 0; i < n; ++i) cout << a[i].a << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct cc {
int shu;
int xiabiao;
};
int b[3000001];
cc p[3000001];
int a2[3000001];
int cmp(cc a, cc b) { return a.shu < b.shu; }
int main() {
int a;
int k = 0;
while (~scanf("%d", &a)) {
for (int i = 0; i < a; i++) {
scanf("%d", &p[i].shu);
p[i].xiabiao = i;
}
sort(p, p + a, cmp);
int q = p[0].shu;
a2[p[0].xiabiao] = q;
for (int i = 1; i < a; i++) {
if (p[i].shu <= q) {
a2[p[i].xiabiao] = ++q;
} else {
q = p[i].shu;
a2[p[i].xiabiao] = q;
}
}
int k = 0;
for (int i = 0; i < a; i++) {
printf("%d ", a2[i]);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
pair<int, int> angka[300004];
bool cpr(pair<int, int> a, pair<int, int> b) { return (a.second <= b.second); }
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &angka[i].first);
angka[i].second = i;
}
sort(angka + 1, angka + n + 1);
for (int i = 2; i <= n; i++) {
if (angka[i - 1].first >= angka[i].first) {
angka[i].first += angka[i - 1].first - angka[i].first + 1;
}
}
sort(angka + 1, angka + n + 1, cpr);
for (int i = 1; i <= n; i++) {
if (i != 1) printf(" ");
printf("%d", angka[i].first);
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
struct p {
int a, num, u;
} s[3000000];
bool cmpa(p x, p y) { return x.a < y.a; }
bool cmpnum(p x, p y) { return x.num < y.num; }
int main() {
int i, used = 0;
scanf("%d", &n);
for (i = 1; i <= n; ++i) {
scanf("%d", &s[i].a);
s[i].num = i;
}
sort(s + 1, s + n + 1, cmpa);
for (i = 1; i <= n; ++i) {
if (used < s[i].a)
used = s[i].a;
else
++used;
s[i].u = used;
}
sort(s + 1, s + n + 1, cmpnum);
for (i = 1; i <= n; ++i) printf("%d ", s[i].u);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
long long a[n];
long long t[n];
long long b[n];
map<long long, long long> m;
for (int i = 0; i < n; i++) {
scanf("%I64d", &a[i]);
t[i] = a[i];
}
sort(a, a + n);
map<long long, long long> temp;
map<long long, long long> mm;
map<long long, long long> st;
map<long long, long long> en;
for (int i = 0; i < n; i++) {
if (!st[a[i]]) {
if (i - 1 >= 0) {
st[a[i]] = en[a[i]] = max(en[a[i - 1]] + 1, a[i]);
} else
st[a[i]] = en[a[i]] = a[i];
} else {
en[a[i]]++;
}
m[a[i]]++;
}
int c = 0;
for (int i = 0; i < n; i++) {
b[c++] = st[t[i]] + temp[t[i]];
temp[t[i]]++;
}
for (int i = 0; i < n; i++) {
printf("%I64d", b[i]);
printf(" ");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
struct Node {
int val, x;
} node[maxn];
int a[maxn];
bool cmp(Node n1, Node n2) { return n1.val < n2.val; }
int main() {
int n, i;
vector<int> vec;
set<int> S;
set<int>::iterator it1, it2;
while (cin >> n) {
int k = 0;
for (i = 0; i < n; i++) {
cin >> node[k].val;
node[k++].x = i;
}
sort(node, node + k, cmp);
int m = 0;
for (i = 0; i < k; i++) {
m = max(m, node[i].val);
a[node[i].x] = m;
m++;
}
for (i = 0; i < n - 1; i++) cout << a[i] << " ";
cout << a[i] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ans[300020];
int main() {
vector<pair<long long, int> > a;
int n, x;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x;
a.push_back(make_pair(x, i));
}
sort(a.begin(), a.end());
ans[a[0].second] = a[0].first;
for (int i = 1; i < n; i++) {
if (ans[a[i - 1].second] >= a[i].first)
ans[a[i].second] = ans[a[i - 1].second] + 1;
else
ans[a[i].second] = a[i].first;
}
for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300300;
struct El {
int index;
int rating;
};
int n;
El vec[MAXN];
int ans[MAXN];
void read() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &vec[i].rating);
vec[i].index = i;
}
}
bool cmp(El a, El b) {
if (a.rating != b.rating) return a.rating < b.rating;
return a.index < b.index;
}
void solve() {
sort(vec, vec + n, cmp);
int tmp = 0;
for (int i = 0; i < n; i++) {
if (tmp < vec[i].rating) tmp = vec[i].rating;
ans[vec[i].index] = tmp;
tmp++;
}
for (int i = 0; i < n; i++) {
if (i) printf(" ");
printf("%d", ans[i]);
}
cout << endl;
}
int main() {
read();
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[300200];
int c[300200];
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
sort(a, a + n);
int cur = a[0].first;
for (int i = 0; i < n; i++) {
if (a[i].first <= cur)
c[a[i].second] = cur, cur++;
else if (a[i].first > cur)
cur = a[i].first + 1, c[a[i].second] = a[i].first;
}
for (int i = 0; i < n; i++) cout << c[i] << ' ';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
pair<int, int> p[n];
for (int i = 0; i < n; i++) {
cin >> p[i].first;
p[i].second = i;
}
sort(p, p + n);
int res[n];
int b[n], ans[n];
for (int i = 0; i < n; i++) b[i] = p[i].first;
for (int i = 1; i < n; i++) {
if (b[i] <= b[i - 1] + 1) b[i] = b[i - 1] + 1;
}
for (int i = 0; i < n; i++) res[p[i].second] = b[i];
for (int i = 0; i < n; i++) cout << res[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Node {
int a, pos;
bool operator<(const Node &o) const { return a < o.a; }
};
int main() {
int n, b[300010];
Node user[300010];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &user[i].a);
user[i].pos = i;
}
sort(user, user + n);
int actual = 0;
for (int i = 0; i < n; i++) {
b[user[i].pos] = max(user[i].a, actual + 1);
actual = b[user[i].pos];
}
for (int i = 0; i < n; i++) printf("%d ", b[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
struct ps {
int v, p;
} pss[300005];
bool cmp(const ps &a, const ps &b) { return a.v < b.v; }
int main() {
int n, ns[300005];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> pss[i].v;
pss[i].p = i;
}
sort(pss, pss + n, cmp);
int mn = 0;
for (int i = 0; i < n; i++) {
ns[pss[i].p] = max(pss[i].v, mn);
mn = ns[pss[i].p] + 1;
}
for (int i = 0; i < n; i++) cout << ns[i] << ' ';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, ans[1000000];
pair<int, int> val[1000000];
bool solve() {
if (scanf("%d", &n) == EOF) return false;
for (int i = 0; i < n; ++i) {
scanf("%d", &val[i]);
val[i].second = i;
}
sort(val, val + n);
int k = -1;
for (int i = 0; i < n; ++i) {
ans[val[i].second] = max(k, val[i].first);
k = ans[val[i].second] + 1;
}
for (int i = 0; i < n; ++i) printf(i == n - 1 ? "%d\n" : "%d ", ans[i]);
return true;
}
int main() {
while (solve())
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
template <class T>
inline T sqr(T x) {
return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n;
pair<long long, int> a[300010];
long long ans[300010];
long long cur;
int main() {
cin >> n;
for (int i = (0); i < (n); ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a, a + n);
cur = a[0].first;
ans[a[0].second] = cur;
for (int i = 1; i < n; ++i) {
if (cur >= a[i].first) {
ans[a[i].second] = cur + 1;
++cur;
} else {
ans[a[i].second] = a[i].first;
cur = a[i].first;
}
}
for (int i = (0); i < (n - 1); ++i) cout << ans[i] << " ";
cout << ans[n - 1] << endl;
return 0;
}
|
#include <bits/stdc++.h>
int n;
struct list {
int x, pos;
};
list data[300005];
std::map<int, int> v;
std::set<int> check;
bool sf(list a, list b) { return a.x < b.x; }
bool sf2(list a, list b) { return a.pos < b.pos; }
int main() {
int i, num = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &data[i].x);
v[data[i].x]++;
data[i].pos = i;
}
std::sort(data + 1, data + n + 1, sf);
num = data[1].x;
for (i = 1; i <= n; i++) {
if (check.find(data[i].x) == check.end()) {
check.insert(data[i].x);
continue;
}
if (v[data[i].x] == 1) continue;
if (num < data[i].x) num = data[i].x;
while (v.find(num) != v.end()) num++;
data[i].x = num;
v[num] = 1;
}
std::sort(data + 1, data + n + 1, sf2);
for (i = 1; i <= n; i++) printf("%d ", data[i].x);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a;
int r[300010];
int main() {
int n, m;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int aux;
scanf("%d", &aux);
a.push_back(make_pair(aux, i));
}
sort(a.begin(), a.end());
m = 1;
for (int i = 0; i < n; i++) {
r[a[i].second] = max(a[i].first, m);
m = max(a[i].first, m) + 1;
}
for (int i = 0; i < n; i++) {
printf("%d ", r[i]);
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool customS(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
if (a.second == b.second) return a.first < b.first;
return a.second < b.second;
}
bool customS2(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
return a.first < b.first;
}
class CompareDist {
public:
bool operator()(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
return a.first < b.first;
}
};
int64_t gcd(int64_t a, int64_t b) {
if (b == 0) return a;
return gcd(b, a % b);
}
double gcdfloat(double a, double b) {
if (a < b) return gcd(b, a);
if (fabs(b) < 0.001)
return a;
else
return (gcd(b, a - floor(a / b) * b));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, i;
cin >> n;
vector<pair<int64_t, int64_t> > arr(n);
for (i = 0; i < n; i++) {
cin >> arr[i].second;
arr[i].first = i;
}
sort(arr.begin(), arr.end(), customS);
int ctr = 1;
for (i = 0; i < n; i++) {
if (arr[i].second > ctr) {
ctr = arr[i].second;
ctr++;
} else {
arr[i].second = ctr;
ctr++;
}
}
sort(arr.begin(), arr.end(), customS2);
for (i = 0; i < n; i++) {
cout << arr[i].second << " ";
}
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return (a.second < b.second);
}
void Mr_Kul() {
int n;
cin >> n;
vector<pair<long long, long long> > m;
for (int i = 0; i < n; i++) {
int k;
cin >> k;
m.push_back({k, i});
}
sort(m.begin(), m.end());
for (int i = 1; i < n; i++) {
if (m[i].first <= m[i - 1].first) {
int d = m[i - 1].first - m[i].first;
m[i].first += d + 1;
}
}
sort(m.begin(), m.end(), sortbysec);
for (int i = 0; i < n; i++) {
cout << m[m[i].second].first << " ";
}
}
int main() { Mr_Kul(); }
|
#include <bits/stdc++.h>
using namespace std;
int i, k, n, b[400009];
pair<int, int> a[400009];
int main() {
cin >> n;
for (i = 1; i <= n; i++) {
scanf("%d", &k);
a[i] = {k, i};
}
sort(a + 1, a + n + 1);
for (i = 1; i <= n; i++)
if (a[i - 1].first >= a[i].first) a[i].first = a[i - 1].first + 1;
for (i = 1; i <= n; i++) b[a[i].second] = a[i].first;
for (i = 1; i <= n; i++) printf("%d ", b[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, i, j, k, p;
cin >> n;
vector<int> a(n), ans(n, -1);
map<int, int> ct;
unordered_set<int> s;
vector<pair<int, int>> plist;
for (i = 0; i < n; i++) {
cin >> a[i];
if (ct[a[i]] == 0) {
ct[a[i]]++;
ans[i] = a[i];
s.insert(a[i]);
} else {
plist.push_back({a[i], i});
}
}
sort(plist.begin(), plist.end());
p = 1;
for (auto pp : plist) {
while ((p < pp.first) || (s.find(p) != s.end())) p++;
s.insert(p);
ans[pp.second] = p;
}
for (i = 0; i < n; i++) cout << ans[i] << " ";
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
long long int val;
int pos;
};
bool comp(struct node a, struct node b) { return a.val < b.val; }
long long int rating[300005];
int main() {
int n, i;
vector<struct node> v;
struct node s;
cin >> n;
for (i = 0; i < n; i++) {
cin >> rating[i];
s.val = rating[i];
s.pos = i;
v.push_back(s);
}
sort(v.begin(), v.end(), comp);
long long int mi = 0;
for (i = 0; i < v.size(); i++) {
if (v[i].val <= mi) {
v[i].val = mi + 1;
}
rating[v[i].pos] = v[i].val;
mi = v[i].val;
}
for (i = 0; i < n; i++) {
cout << rating[i] << " ";
}
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct st {
int rat, id;
bool operator<(const st& k) const { return rat < k.rat; }
} s[300002];
int n, ans[300002];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &s[i].rat), s[i].id = i;
sort(s, s + n);
int lb = 0;
for (int i = 0; i < n; i++) {
lb++;
lb = max(lb, s[i].rat);
ans[s[i].id] = lb;
}
for (int i = 0; i < n; i++) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<pair<long int, int>> a, b;
for (int i = 0; i < n; i++) {
long int s;
pair<long int, int> p;
cin >> s;
p.first = s;
p.second = i;
a.push_back(p);
}
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
pair<long int, int> p;
if (i == 0) {
p.first = a[i].first;
p.second = a[i].second;
b.push_back(p);
continue;
}
if (a[i].first > b[i - 1].first) {
p.first = a[i].first;
p.second = a[i].second;
b.push_back(p);
} else {
p.first = b[i - 1].first + 1;
p.second = a[i].second;
b.push_back(p);
}
}
long int s[400000]{0};
for (int i = 0; i < n; i++) {
s[b[i].second] = b[i].first;
}
for (int i = 0; i < n; i++) cout << s[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int MXX = 3e5 + 5;
pair<int, int> a[MXX];
long long int b[MXX];
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
int n;
scanf("%d", &n);
for (int i = (0); i < (n); i++) scanf("%d", &a[i].first), a[i].second = i;
sort(a, a + n);
long long int currval = 0;
for (int i = (0); i < (n); i++) {
if (a[i].first > currval) {
b[a[i].second] = a[i].first;
currval = a[i].first + 1;
} else {
b[a[i].second] = currval;
currval++;
}
}
for (int i = (0); i < (n); i++) printf("%lld ", b[i]);
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> num[400000];
long long ans[400000];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
long long t;
cin >> t;
num[i] = pair<long long, long long>(t, i);
}
sort(num, num + n);
long long yu = 0;
for (int i = 1; i < n; i++) {
if (num[i].first <= num[i - 1].first)
num[i].first += -num[i].first + num[i - 1].first + 1;
}
for (int i = 0; i < n; i++) ans[num[i].second] = num[i].first;
for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
struct Data {
int val;
int id;
};
bool cmp(Data a, Data b) { return a.val < b.val; }
int n, arr[300010], cnt, idx, mn;
Data data[300010];
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> arr[i];
data[i].val = arr[i];
data[i].id = i;
}
sort(data, data + n, cmp);
mn = data[0].val;
arr[0] = mn;
for (int i = 1; i < n; ++i) {
if (data[i].val <= mn) {
arr[data[i].id] = mn + 1;
mn++;
} else {
mn = data[i].val;
arr[data[i].id] = mn;
}
}
for (int i = 0; i < n; ++i) cout << arr[i] << " ";
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, res[300000], cur = 0;
pair<int, int> a[300000];
cin.sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
sort(a, a + n);
for (int i = 0; i < n; i++) {
cur = max(a[i].first, cur + 1);
res[a[i].second] = cur;
}
for (int i = 0; i < n; i++) cout << res[i] << ' ';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
struct Node {
int val, x;
} node[maxn];
int a[maxn];
bool cmp(Node n1, Node n2) { return n1.val < n2.val; }
int main() {
int n, i;
while (cin >> n) {
int k = 0;
for (i = 0; i < n; i++) {
scanf("%d", &node[k].val);
node[k++].x = i;
}
sort(node, node + k, cmp);
int m = 0;
for (i = 0; i < k; i++) {
m = max(m, node[i].val);
a[node[i].x] = m;
m++;
}
for (i = 0; i < n - 1; i++) printf("%d ", a[i]);
printf("%d\n", a[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int oo = 999999999;
const double PI = 3.1415931;
const double eps = 1e-9;
const int maxN = 1000 * 300 + 10;
pair<int, int> a[maxN];
int ans[maxN];
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
int last = 0;
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; i++) {
ans[a[i].second] = max(last + 1, a[i].first);
last = ans[a[i].second];
}
for (int i = 1; i <= n; i++) cout << ans[i] << " ";
cout << endl;
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 3 * 1000 * 100 + 10;
int n;
pair<int, int> a[Maxn];
bool q(pair<int, int> b, pair<int, int> c) { return b.second < c.second; }
int main() {
cin >> n;
for (int i = 0; i < n; a[i].second = i++) cin >> a[i].first;
sort(a, a + n);
int t = a[0].first;
for (int i = 1; i < n; i++) {
if (a[i].first <= t) a[i].first = t + 1;
t = max(t, a[i].first);
}
sort(a, a + n, q);
for (int i = 0; i < n; i++) cout << a[i].first << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long inf = (((long long)1) << 61) + 5;
const int N = 300005;
pair<int, int> a[N];
int b[N];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a[i] = make_pair(x, i);
}
sort(a, a + n);
int m = 1;
for (int i = 0; i < n; i++) {
m = max(a[i].first, m);
b[a[i].second] = m;
m++;
}
for (int i = 0; i < n; i++) printf("%d ", b[i]);
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortBySecond(pair<long, long> a, pair<long, long> b) {
return a.second < b.second;
}
int main() {
long n, temp;
cin >> n;
vector<pair<long, long>> v(n);
for (int i = 0; i < n; i++) {
cin >> temp;
v[i] = make_pair(temp, i);
}
sort(v.begin(), v.end());
long c = 0;
for (int i = 1; i < n; i++) {
if (v[i].first == v[i - 1].first) {
v[i].first++;
} else if (v[i].first < v[i - 1].first) {
v[i].first = v[i - 1].first + 1;
}
}
sort(v.begin(), v.end(), sortBySecond);
for (int i = 0; i < n; i++) cout << v[i].first << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[300005], r[300005], b[300005];
set<int> s;
bool cmp(int i, int j) { return a[i] < a[j]; }
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]), r[i] = i;
sort(r, r + n, cmp);
for (int i = 0; i < n; i++) {
if (!s.count(a[r[i]]))
b[r[i]] = a[r[i]];
else
b[r[i]] = b[r[i - 1]] + 1;
s.insert(b[r[i]]);
}
for (int i = 0; i < n; i++) cout << b[i] << ' ';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, j, k, temp = 0, ans = 0, flag = true, l, sum = 0, m,
mn = 1000000000000000007, mx, count = 0, rest = 0;
cin >> n;
vector<pair<long long int, long long int> > v;
vector<long long int> rate(1000006, 0);
for (i = 0; i < n; i++) {
cin >> k;
v.push_back(make_pair(k, i));
}
sort(v.begin(), v.end());
rate[v[0].second] = v[0].first;
temp = v[0].first;
for (i = 1; i < n; i++) {
temp++;
if (v[i].first <= temp) {
rate[v[i].second] = temp;
} else {
temp = v[i].first;
rate[v[i].second] = temp;
}
}
for (i = 0; i < n; i++) {
cout << rate[i] << " ";
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long a[N];
vector<pair<long long, long long> > v;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
v.push_back(make_pair(a[i], i));
}
sort(v.begin(), v.end());
for (int i = 1; i < n; i++) {
if (v[i].first <= v[i - 1].first) v[i].first = v[i - 1].first + 1;
}
for (int i = 0; i < n; i++) {
swap(v[i].first, v[i].second);
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
cout << v[i].second << " ";
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.