text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int n, t, a[300005], p[300005], ret[300005]; bool cmp(int x, int y) { return a[x] < a[y]; } int main() { scanf("%d", &n); for (int i = (0); i < (n); i++) scanf("%d", &a[i]), p[i] = i; sort(p, p + n, cmp); t = 0; for (int i = (0); i < (n); i++) { t = max(t + 1, a[p[i]]); ret[p[i]] = t; } for (int i = (0); i < (n); i++) printf("%d ", ret[i]); return 0; }
#include <bits/stdc++.h> using namespace std; struct st { int r, id; }; st ar[300010]; bool cmp(st a, st b) { return a.r < b.r; } bool cmp1(st a, st b) { return a.id < b.id; } int main() { int n, x; while (cin >> n) { for (int i = 0; i < n; ++i) { scanf("%d", &x); ar[i].r = x; ar[i].id = i; } sort(ar, ar + n, cmp); for (int i = 1; i < n; ++i) { if (ar[i].r <= ar[i - 1].r) ar[i].r = ar[i - 1].r + 1; } sort(ar, ar + n, cmp1); for (int i = 0; i < n; ++i) { if (!i) printf("%d", ar[i].r); else printf(" %d", ar[i].r); } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int s; int r; }; vector<node> asd; int n; node temp; int comp(node x, node y) { if (x.s >= y.s) return 0; return 1; } int comp2(node x, node y) { if (x.r >= y.r) return 0; return 1; } int main() { int a, syc; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a); temp.s = a; temp.r = i; asd.push_back(temp); } sort(asd.begin(), asd.end(), comp); syc = asd[0].s; for (int i = 0; i < asd.size(); i++) { if (asd[i].s > syc) syc = asd[i].s; asd[i].s = syc; syc++; } sort(asd.begin(), asd.end(), comp2); for (int i = 0; i < asd.size(); i++) printf("%d ", asd[i].s); }
#include <bits/stdc++.h> using namespace std; struct ra { int x, id; bool operator<(const ra &b) const { return x < b.x || x == b.x && id < b.id; } }; ra p[300005]; int ans[300005], n, mi; int main() { while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) { scanf("%d", &p[i].x); p[i].id = i; } sort(p, p + n); mi = p[0].x; for (int i = 0; i < n; i++) { if (p[i].x < mi) { ans[p[i].id] = mi; mi++; } else { ans[p[i].id] = p[i].x; mi = p[i].x + 1; } } for (int i = 0; i < n - 1; i++) { printf("%d ", ans[i]); } printf("%d\n", ans[n - 1]); } return 0; }
#include <bits/stdc++.h> using namespace std; int a[3][400000], n; void swap(int &a, int &b) { int t = a; a = b; b = t; } void quicksort(int l, int h, int x) { if (l < h) { int i = l, j = h, k = a[x][rand() % (h - l + 1) + l]; do { while (a[x][i] < k) i++; while (a[x][j] > k) j--; if (i <= j) { if (i < j) { swap(a[0][i], a[0][j]); swap(a[1][i], a[1][j]); swap(a[2][i], a[2][j]); } i++; j--; } } while (i <= j); quicksort(l, j, x); quicksort(i, h, x); } } void enter() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[0][i]); a[1][i] = i; } a[0][n] = 1000000001; quicksort(0, n - 1, 0); int x = a[0][0]; int i = 0; while (i < n) { a[2][i] = x; if (a[0][i] == a[0][i + 1]) { x++; } else { if (x < a[0][i + 1]) x = a[0][i + 1]; else x++; } i++; } quicksort(0, n - 1, 1); for (int i = 0; i < n - 1; i++) printf("%d ", a[2][i]); printf("%d", a[2][n - 1]); } int main() { enter(); return 0; }
#include <bits/stdc++.h> using namespace std; const int oo = INT_MAX; bool s(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { int n; cin >> n; long long l = -1; pair<int, int> x[n]; for (int i = 0; i < n; i++) cin >> x[i].first, x[i].second = i; sort(x, x + n); for (int i = 0; i < n; i++) { if (l > x[i].first) x[i].first = l, l++; else l = x[i].first + 1; } sort(x, x + n, s); for (int i = 0; i < n; i++) cout << x[i].first << ' '; return 0; }
#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() { 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> using namespace std; using namespace std::chrono; bool SoSec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } void vw(vector<vector<int>> v) { cout << (v.size()) << " is: " << endl; for (vector<int> B : v) { for (int x : B) { cout << x << " "; } cout << endl; } cout << endl; } void v23(vector<int> v) { cout << (v.size()) << " is: " << endl; for (int i : v) { cout << i << " "; } cout << endl; } long long Sqrt(long long x) { if (x == 0 || x == 1) return x; long long start = 1, end = x, ans; while (start <= end) { long long mid = (start + end) / 2; if (mid * mid == x) return mid; if (mid * mid < x) { start = mid + 1; ans = mid; } else end = mid - 1; } return ans; } vector<vector<int>> v; long long const MAX = 2147483647, REALMAX = 9223372036854775806; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<pair<int, int>> v(n); for (int i = 0; i < n; i++) { cin >> v[i].first; v[i].second = i + 1; } 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; } sort(v.begin(), v.end(), SoSec); for (int i = 0; i < n; i++) { cout << v[i].first << " "; } }
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::get; using std::max; using std::min; using std::pair; using std::sort; using std::string; using std::tie; using std::tuple; int main() { int n; cin >> n; pair<int, int> num[n]; for (int i = 0; i < n; i++) { cin >> num[i].first; num[i].second = i; } sort(num, num + n, [](const pair<int, int>& x, const pair<int, int>& y) { return x.first < y.first; }); for (int i = 1; i < n; i++) { num[i].first = max(num[i].first, 1 + num[i - 1].first); } sort(num, num + n, [](const pair<int, int>& x, const pair<int, int>& y) { return x.second < y.second; }); for (int i = 0; i < n; i++) { cout << num[i].first << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; int n; int st; int a[300000 + 5]; int b[300000 + 5]; int c[300000 + 5]; int ans[300000 + 5]; bool cmp(int u, int v) { return a[u] < a[v]; } int main() { cin >> n; for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i]; for (int i = (1), _b = (n); i <= _b; i++) b[i] = i; sort(b + 1, b + n + 1, cmp); sort(a + 1, a + n + 1); st = a[1]; for (int i = 1; i <= n; i++) { if (st >= a[i]) { c[i] = st; st++; } else if (st < a[i]) { st = a[i]; c[i] = st; st++; } } for (int i = (1), _b = (n); i <= _b; i++) ans[b[i]] = c[i]; for (int i = (1), _b = (n); i <= _b; i++) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int64_t sumn(int64_t n) { return ((n) * (n + 1)) / 2; } int main() { int n; cin >> n; vector<pair<long long, long long> > a(n); vector<long long> b(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); long long curr = a[0].first; b[a[0].second] = curr; curr++; for (int i = 1; i < n; i++) { if (a[i].first < curr) { b[a[i].second] = curr; curr++; } else { b[a[i].second] = a[i].first; curr = a[i].first + 1; } } for (int i = 0; i < n; i++) cout << b[i] << " "; cout << "\n"; }
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[300005]; bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { int n; cin >> n; int i, x; for (i = 0; i < n; i++) { cin >> x; arr[i].first = x; arr[i].second = i; } sort(arr, arr + n); for (i = 1; i < n; i++) { if (arr[i].first <= arr[i - 1].first) { arr[i].first = arr[i - 1].first + 1; } } sort(arr, arr + n, comp); for (i = 0; i < n; i++) { cout << arr[i].first << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s) { return __builtin_popcount(s); } template <class T> inline T gcd(T a, T b) { T r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long n, b[300005]; pair<long long, long long> a[300005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (long long i = 1, _b = n; i <= _b; i++) { cin >> a[i].first; a[i].second = i; } sort(a + 1, a + n + 1); long long dau = a[1].first; for (long long i = 1, _b = n; i <= _b; i++) { if (a[i].first > dau) { dau = a[i].first; } b[a[i].second] = dau; dau++; } for (long long i = 1, _b = n; i <= _b; i++) cout << b[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; struct Rate { int r; int id; } rate[300005]; int num[300005]; bool cmp2(Rate R1, Rate R2) { return R1.r < R2.r; } int main() { int n; while (~scanf("%d", &n)) { for (int i = 0; i < n; i++) { rate[i].id = i; scanf("%d", &rate[i].r); } sort(rate, rate + n, cmp2); int s = rate[0].r; for (int i = 0; i < n; i++) if (s >= rate[i].r) num[rate[i].id] = s++; else if (s < rate[i].r) { s = num[rate[i].id] = rate[i].r; s++; } printf("%d", num[0]); for (int i = 1; i < n; i++) printf(" %d", num[i]); puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 3 * 10e5 + 10; int ans[N]; vector<pair<int, int> > v; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(make_pair(x, i)); } sort(v.begin(), v.end()); ans[v[0].second] = v[0].first; for (int i = 1; i < n; i++) { if (v[i].first == v[i - 1].first) { ans[v[i].second] = ans[v[i - 1].second] + 1; } else { if (v[i].first <= ans[v[i - 1].second]) ans[v[i].second] = ans[v[i - 1].second] + 1; else ans[v[i].second] = v[i].first; } } for (int i = 0; i < n; i++) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; const int MaxN = int(1e6) + 123; long long n, q, A[MaxN], c; pair<long long, long long> a[MaxN]; 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++) { c = max(a[i].first, c); A[a[i].second] = c; c++; } for (int i = 1; i <= n; i++) { cout << A[i] << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long int Mx = 1e9 + 10; const int maxN = 3 * 1e5; long long int n, tmp, a[maxN + 10], b[maxN + 10], now, ans[maxN + 10]; map<unsigned int, long long int> m; inline bool cm(const long long int u, const long long int v) { return a[u] < a[v]; } int main() { cin >> n; for (int i = 0; i < n; i++) b[i] = i; for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; } sort(b, b + n, cm); now = 0; for (int i = 0; i < n; i++) { if (now < a[b[i]]) now = a[b[i]]; ans[b[i]] = now; now++; m[a[b[i]]]--; } for (int i = 0; i < n; i++) cout << ans[i] << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int Find(int x) { if (mp.find(x) == mp.end()) return x; return mp[x] = Find(mp[x]); } int main() { int n; while (scanf("%d", &n) != EOF) { mp.clear(); int a; for (int i = 0; i < n; i++) { scanf("%d", &a); a = Find(a); mp[a] = a + 1; if (i) printf(" "); printf("%d", a); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; struct pt { int a, id; }; bool comp(pt a, pt b) { return a.a < b.a || (a.a == b.a && a.id < b.id); } pt w[300001]; int ans[300001]; int main() { int n, i, mx, cur; cin >> n; for (i = 1; i <= n; i++) cin >> w[i].a, w[i].id = i; sort(w + 1, w + n + 1, comp); cur = w[1].a; for (i = 1; i <= n; i++) { if (w[i].a > cur) ans[w[i].id] = w[i].a, cur = w[i].a + 1; else ans[w[i].id] = cur++; } for (i = 1; i <= n; i++) cout << ans[i] << " "; }
#include <bits/stdc++.h> using namespace std; int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1}; int dx4[] = {1, 0, -1, 0}; int dy4[] = {0, 1, 0, -1}; template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << "\n"; ; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &a) { return out << "(" << a.first << "," << a.second << ")"; } template <class A> ostream &operator<<(ostream &out, const vector<A> &a) { for (const A &it : a) out << it << " "; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { return in >> a.first >> a.second; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &i : a) in >> i; return in; } template <typename T, typename T1> T amax(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } bool compare(pair<int, int> p1, pair<int, int> p2) { return p1.second < p2.second; } void solve() { int n; 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()); int i = 1; while (i < n) { if (v[i].first <= v[i - 1].first) { v[i].first = v[i - 1].first + 1; } i++; } sort((v).begin(), (v).end(), compare); for (int i = 0; i < n; i++) { cout << v[i].first << " "; } cout << "\n"; ; } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double PI = atan(1.0) * 4; const int inf = 2147483647 / 2; inline int Mymod(int a, int b) { int x = a % b; if (x < 0) x += b; return x; } map<int, int> mp; int find(int t) { if (mp.count(t)) mp[t] = find(mp[t]); else mp[t] = t + 1; return mp[t]; } int main() { int n; while (scanf("%d", &n) != EOF) { mp.clear(); int t; for (int i = 0; i < n; ++i) { scanf("%d", &t); t = find(t); if (i) printf(" "); printf("%d", t - 1); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 113; int n; pair<int, int> coor[N]; int last = -1, ans[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> coor[i].first; coor[i].second = i; } sort(coor + 1, coor + n + 1); for (int i = 1; i <= n; i++) { last = max(last + 1, coor[i].first); ans[coor[i].second] = last; } for (int i = 1; i <= n; i++) { cout << ans[i] << ' '; } }
#include <bits/stdc++.h> using namespace std; const int N = 3000 * 100 + 10; int n; long long a[N]; pair<long long, long long> b[N]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i].first = a[i]; b[i].second = i; } sort(b, b + n); for (int i = 1; i < n; i++) if (b[i].first <= b[i - 1].first) b[i].first = b[i - 1].first + 1; for (int i = 0; i < n; i++) swap(b[i].first, b[i].second); sort(b, b + n); for (int i = 0; i < n; i++) cout << b[i].second << " "; cout << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int Maxn = 3 * 1e5 + 3; pair<int, int> num[Maxn]; int n, ans[Maxn], en = -1; void up(int st); int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> num[i].first; num[i].second = i; } sort(num, num + n); for (int i = 0; i < n; ++i) up(i); for (int i = 0; i < n; ++i) cout << ans[i] << ' '; cout << endl; return 0; } void up(int st) { en = ans[num[st].second] = max(num[st].first, en + 1); }
#include <bits/stdc++.h> using namespace std; struct node { int x; int y; }; node t[400005]; int n, i, now, ans[400005]; int cmp(node i, node j) { return i.x < j.x; } int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &t[i].x); t[i].y = i; } sort(t + 1, t + n + 1, cmp); now = 0; for (i = 1; i <= n; i++) { now = max(now + 1, t[i].x); ans[t[i].y] = now; } for (i = 1; i <= n; i++) printf("%d ", ans[i]); return 0; }
#include <bits/stdc++.h> using namespace std; void print_vector(vector<int> v); void print_array(int* array, int start, int end); vector<pair<int, int> > all, nvi; int n, x; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { scanf("%d", &n); for (int i = (0), _b = (n); i < _b; i++) { cin >> x; all.push_back(pair<int, int>(x, i)); } sort((all).begin(), (all).end()); nvi.push_back(all[0]); for (int i = (1), _b = (n); i < _b; i++) { if (all[i].first > nvi[i - 1].first) nvi.push_back(all[i]); else nvi.push_back(pair<int, int>(nvi[i - 1].first + 1, all[i].second)); } sort((nvi).begin(), (nvi).end(), cmp); for (int i = (0), _b = (n); i < _b; i++) { if (i) printf(" "); printf("%d", nvi[i].first); } printf("\n"); return 0; } void print_array(int* array, int start, int end) { printf("["); for (int i = (start), _b = (end); i < _b; i++) { printf("%d ", array[i]); } printf("]"); printf("\n"); } void print_vector(vector<int> v) { printf("["); for (int i = (0), _b = (v.size()); i < _b; i++) { printf("%d ", v[i]); } printf("]"); printf("\n"); }
#include <bits/stdc++.h> using namespace std; struct qw { int val; int index; } st[300005]; bool MyCompare(int a, int b) { return a < b; } int max(int a, int b) { return a > b ? a : b; } int min(int a, int b) { return a < b ? a : b; } int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } bool MyCompare1(qw a, qw b) { return a.val < b.val; } bool MyCompare2(qw a, qw b) { return a.index < b.index; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &st[i].val); st[i].index = i; } sort(st, st + n, MyCompare1); int tmp = st[0].val; for (int i = 1; i < n; i++) { if (st[i].val == tmp) { st[i].val = ++tmp; } else { if (st[i].val > tmp) { tmp = st[i].val; } else { st[i].val = ++tmp; } } } sort(st, st + n, MyCompare2); for (int i = 0; i < n; i++) { printf("%d ", st[i].val); } return 0; }
#include <bits/stdc++.h> using namespace std; using namespace std; long ans[100005] = {0}; using namespace std; int n, x, b[300005]; pair<int, int> a[300005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; a[i] = make_pair(x, i); } sort(a + 1, a + n + 1); x = 0; for (int i = 1; i <= n; i++) { if (a[i].first > x) { x = a[i].first; b[a[i].second] = x; x++; } else { b[a[i].second] = x; x++; } } for (int i = 1; i <= n; i++) cout << b[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 505; map<int, int> ma; int dfs(int x) { if (ma.find(x) == ma.end()) return x; return ma[x] = dfs(ma[x]); } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); x = dfs(x); ma[x] = x + 1; if (i) cout << " "; cout << x; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, i, now, a[310000], tx[310000], ans[310000]; bool cmp(int x, int y) { return a[x] < a[y]; } int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); tx[i] = i; } sort(tx + 1, tx + n + 1, cmp); for (i = 1; i <= n; i++) { now = max(now + 1, a[tx[i]]); ans[tx[i]] = now; } for (i = 1; i <= n; i++) { printf("%d ", ans[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[300005]; bool comp(const pair<int, int>& P1, const pair<int, int>& P2) { return P1.second < P2.second; } int main() { int n; cin >> n; int a; for (int i = 0; i < n; i++) { scanf("%d", &a); arr[i] = {a, i}; } sort(arr, arr + n); int last = -1; for (int i = 0; i < n; i++) { if (last < arr[i].first) { last = arr[i].first; } else { arr[i].first = last + 1; last++; } } sort(arr, arr + n, comp); for (int i = 0; i < n; i++) { cout << arr[i].first << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); std::ios::sync_with_stdio(false); long long x, n; cin >> n; vector<pair<long long, long long> > v; for (int i = 0; i < n; i++) { cin >> x; v.push_back({x, i}); } sort(v.begin(), v.end()); map<long long, bool> maap; x = v[0].first; vector<pair<long long, long long> > out; for (int i = 0; i < n; i++) { if (maap[x]) { x++; i--; continue; } if (x >= v[i].first) { out.push_back({v[i].second, x}); maap[x] = 1; x++; } else { x = v[i].first; out.push_back({v[i].second, x}); maap[x] = 1; } } sort(out.begin(), out.end()); cout << out[0].second; for (int i = 1; i < out.size(); i++) { cout << " " << out[i].second; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long int modpow(long long int a, long long int n, long long int temp) { long long int res = 1, y = a; while (n > 0) { if (n & 1) res = (res * y) % temp; y = (y * y) % temp; n /= 2; } return res % temp; } long long int gcd(long long int a, long long int b) { if (a == 0) return (b); else return (gcd(b % a, a)); } int main() { long long int n, i, j; cin >> n; vector<long long int> a(n); vector<pair<long long int, long long int> > b(n); for (i = 0; i < n; i++) { cin >> a[i]; b[i] = make_pair(a[i], i); } sort(b.begin(), b.end()); for (i = 1; i < n; i++) if (b[i].first <= b[i - 1].first) b[i].first = b[i - 1].first + 1; for (i = 0; i < n; i++) a[b[i].second] = b[i].first; for (i = 0; i < n; i++) cout << a[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; double eps = 1e-8; int main() { int n; scanf("%d", &n); int a[n]; int b[n]; int c[n]; for (int p = 0; p < n; p++) { scanf("%d", &a[p]); b[p] = a[p]; c[p] = p; } pair<int, int> pairs[n]; for (int i = 0; i < n; ++i) pairs[i] = make_pair(b[i], c[i]); sort(pairs, pairs + n); for (int i = 0; i < n; ++i) { b[i] = pairs[i].first; c[i] = pairs[i].second; } int t = 1; for (int i = 0; i < n; i++) { int t1 = b[i]; if (t1 >= t) { a[c[i]] = t1; t = t1; } else { a[c[i]] = t; } t++; } for (int i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl; }
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 100; pair<int, int> a[maxn]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].first; for (int i = 1; i <= n; i++) a[i].second = i; sort(a + 1, a + 1 + n); int last = a[1].first; for (int i = 2; i <= n; i++) if (a[i].first > last) last = a[i].first; else a[i].first = ++last; for (int i = 1; i <= n; i++) swap(a[i].first, a[i].second); sort(a + 1, a + 1 + n); for (int i = 1; i <= n; i++) cout << a[i].second << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> a[300005]; bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.second < p2.second; } int main() { int n; while (cin >> n) { for (int i = 0; i < n; ++i) { scanf("%d", &a[i].first); a[i].second = i; } sort(a, a + n); for (int i = 1; i < n; ++i) { if (a[i].first <= a[i - 1].first) a[i].first = a[i - 1].first + 1; } sort(a, a + n, cmp); for (int i = 0; i < n; ++i) printf("%d ", a[i].first); cout << endl; } }
#include <bits/stdc++.h> using namespace std; bool compare(const pair<int, int>& i, const pair<int, int>& j) { return i.second < j.second; } bool compare_(const pair<int, int>& i, const pair<int, int>& j) { return i.first < j.first; } int main() { int n; cin >> n; vector<pair<int, int> > x(n); for (int i = 0; i < n; i++) { cin >> x[i].first; x[i].second = i; } sort(x.begin(), x.end(), compare_); cout << endl; vector<pair<int, int> > t(n); int counter = x[0].first; t[0].first = counter; t[0].second = x[0].second; counter++; for (int i = 1; i < n; i++) { if (x[i].first > counter) { counter = x[i].first; t[i].first = counter; t[i].second = x[i].second; } else if (x[i].first == counter) { t[i].first = counter; t[i].second = x[i].second; } else if (counter > x[i].first) { t[i].first = counter; t[i].second = x[i].second; } counter++; } sort(t.begin(), t.end(), compare); for (int i = 0; i < n; i++) cout << t[i].first << " "; return 0; }
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); long n; std::cin >> n; std::vector<std::pair<long long, long long> > v; long long x; for (int i = 0; i < n; i++) { std::cin >> x; v.push_back(std::make_pair(x, i)); } std::sort(v.begin(), v.end()); long long prev = v[0].first; long long a[300007]; memset(a, 0, sizeof(a)); a[v[0].second] = prev; for (int i = 1; i < n; i++) { x = v[i].first; if (x > prev) { a[v[i].second] = x; prev = x; } else { a[v[i].second] = prev + 1; prev++; } } for (int i = 0; i < n; i++) { std::cout << a[i] << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") const int N = 303500; string ans; int a[N]; struct node { int id; int val; bool operator<(node t) const { return val < t.val; } } p[N]; bool cmp(node a, node b) { return a.id < b.id; } int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i].val; p[i].id = i; } sort(p + 1, p + 1 + n); int last = -1; for (int i = 1; i <= n; i++) { if (p[i].val <= last) { p[i].val = last + 1; } last = p[i].val; } sort(p + 1, p + 1 + n, cmp); for (int i = 1; i <= n; i++) if (i == 1) cout << p[i].val; else cout << " " << p[i].val; return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 400 * 1000 + 4, Inf = 1e9 + 10; pair<int, int> a[M]; int b[M]; int main() { ios::sync_with_stdio(false); int n, j = 0; cin >> n; for (int i = 0, x; i < n; i++) { cin >> x; a[i] = make_pair(x, i); } sort(a, a + n); for (int i = 0; i < n; i++) { if (a[i].first <= j) b[a[i].second] = ++j; else j = 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; template <typename T> T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> T ModInv(T b, T m) { return BigMod(b, m - 2, m); } template <typename T> void ia(T a[], int n) { for (int i = 0; i < n; i++) cin >> a[i]; } template <typename T> void pa(T a[], int n) { for (int i = 0; i < n - 1; i++) cout << a[i] << " "; cout << a[n - 1] << endl; } template <typename T> long long int isLeft(T a, T b, T c) { return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y); } template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == '-') { ng = true; ch = getchar(); break; } if (ch >= '0' && ch <= '9') break; } while (1) { n = n * 10 + (ch - '0'); ch = getchar(); if (ch < '0' || ch > '9') break; } return (ng ? -n : n); } template <typename T> inline T POW(T B, T printf) { if (printf == 0) return 1; if (printf & 1) return B * POW(B, printf - 1); else return (POW(B, printf / 2) * POW(B, printf / 2)); } template <typename T> inline T Bigmod(T b, T p, T m) { if (p == 0) return 1; else if (!(p & 1)) return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m; else return ((b % m) * Bigmod(b, p - 1, m)) % m; } template <typename T> inline T Dis(T x1, T y1, T x2, T y2) { return sqrt((x1 - x2 * x1 - x2) + (y1 - y2 * y1 - y2)); } template <typename T> inline T Angle(T x1, T y1, T x2, T y2) { return atan(double(y1 - y2) / double(x1 - x2)); } template <typename T> inline T DIFF(T a, T b) { T d = a - b; if (d < 0) return -d; else return d; } template <typename T> inline T ABS(T a) { if (a < 0) return -a; else return a; } template <typename T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } template <typename T> inline T lcm(T a, T b) { if (a < 0) return lcm(-a, b); if (b < 0) return lcm(a, -b); return a * (b / gcd(a, b)); } template <typename T> inline T euclide(T a, T b, T &x, T &y) { if (a < 0) { T d = euclide(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = euclide(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; y = 0; return a; } else { T d = euclide(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } int Set(int N, int pos) { return N = N | (1 << pos); } int Reset(int N, int pos) { return N = N & ~(1 << pos); } bool Check(int N, int pos) { return (bool)(N & (1 << pos)); } int toInt(string s) { int sm; stringstream second(s); second >> sm; return sm; } int toLlint(string s) { long long int sm; stringstream second(s); second >> sm; return sm; } int cdigittoint(char ch) { return ch - '0'; } bool isVowel(char ch) { ch = toupper(ch); if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E') return true; return false; } bool isConst(char ch) { if (isalpha(ch) && !isVowel(ch)) return true; return false; } int ar[300008]; pair<int, int> p[300008]; int main() { int a, b, c, n, m; int res = 0, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; p[i] = make_pair(a, i); } sort(p, p + n); for (int i = 0; i < n; i++) { if (p[i].first > res) { res = p[i].first; ar[p[i].second] = res; res++; } else { ar[p[i].second] = res; res++; } } for (int i = 0; i < n; i++) cout << ar[i] << " "; }
#include <bits/stdc++.h> using namespace std; int n; vector<pair<long long int, int> > arr; long long int val, ans; bool comp(pair<long long int, int>& a, pair<long long int, int>& b) { return a.second < b.second; } int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i <= n - 1; ++i) { cin >> val; arr.push_back({val, i}); } sort(arr.begin(), arr.end()); ans = arr[0].first + 1; for (int i = 1; i <= n - 1; ++i) { arr[i].first = max(ans, arr[i].first); ans = arr[i].first + 1; } sort(arr.begin(), arr.end(), comp); for (int i = 0; i <= n - 1; ++i) { cout << arr[i].first << " "; } cout << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b) { return a.second < b.second; } int main() { long long int n; cin >> n; long long int a[n]; vector<pair<long long int, long long int>> vp; for (long long int i = 0; i < n; i++) { cin >> a[i]; vp.push_back(make_pair(a[i], i)); } sort(vp.begin(), vp.end()); for (long long int i = 1; i < n; i++) { if (vp[i].first <= vp[i - 1].first) vp[i].first = vp[i - 1].first + 1; } sort(vp.begin(), vp.end(), sortbysec); for (long long int i = 0; i < n; i++) { cout << vp[i].first << " "; } cout << "\n"; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } bool isperfect(long long n) { long long y = sqrt(n); if (n % y == 0 && y * y == n) return true; return false; } bool comp(pair<long long, long long> a, pair<long long, long long> b) { return a.second < b.second; } int main() { long long n, p = 0; cin >> n; vector<long long int> b(n), vec(n); vector<pair<long long, long long> > v(n); map<long long, long long> m; for (long long i = 0; i < n; i++) { cin >> b[i]; v[i].second = b[i]; v[i].first = i; } sort(v.begin(), v.end(), comp); for (int i = 0; i < n; i++) { vec[v[i].first] = max(p, v[i].second); p = vec[v[i].first] + 1; } for (long long i = 0; i < n; i++) cout << vec[i] << " "; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int n, cur, ans[3 * MAXN]; pair<int, int> a[3 * MAXN]; 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); cur = -1; for (int i = 1; i <= n; ++i) { if (a[i].first > cur) { ans[a[i].second] = a[i].first; cur = a[i].first + 1; } else { ans[a[i].second] = cur; cur++; } } for (int i = 1; i <= n; ++i) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; using namespace std; long ans[100005] = {0}; using namespace std; int n, x, b[300005]; pair<int, int> a[300005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; a[i] = make_pair(x, i); } stable_sort(a + 1, a + n + 1); x = 0; for (int i = 1; i <= n; i++) { if (a[i].first > x) { x = a[i].first; b[a[i].second] = x; x++; } else { b[a[i].second] = x; x++; } } for (int i = 1; i <= n; i++) cout << b[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 3 * 100000 + 10; long long a[maxn]; long long n; struct node { int num, pos; } b[maxn]; int cmp(node p, node q) { if (p.num == q.num) return p.pos < q.pos; else return p.num < q.num; } int main() { while (scanf("%d", &n) != EOF) { int x; for (int i = 0; i < n; i++) { scanf("%d", &x); b[i].num = x; b[i].pos = i; } sort(b, b + n, cmp); int k; k = b[0].num; a[b[0].pos] = b[0].num; for (int i = 1; i < n; i++) { if (b[i].num <= k) { a[b[i].pos] = k + 1; k++; } else { a[b[i].pos] = b[i].num; k = b[i].num; } } for (int i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int rx[] = {0, -1, 0, 1, -1, 1, 1, -1}; const int cy[] = {1, 0, -1, 0, 1, 1, -1, -1}; int main() { int n, x; cin >> n; vector<pair<int, int> > ar; vector<int> ans(n, -1); for (int i = 0; i < n; i++) { cin >> x; ar.push_back(make_pair(x, i)); } sort(ar.begin(), ar.end()); x = 0; for (int i = 0; i < n; i++) { x = max(ar[i].first, x); ans[ar[i].second] = x; x++; } for (int i = 0; i < n; i++) { if (i) cout << " "; cout << ans[i]; } cout << endl; 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 = 0; i < n; i++) { num[i].first += yu; if (num[i].first >= num[i + 1].first) yu = num[i].first - num[i + 1].first + 1; else yu = 0; } 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; long long pw(long long x, long long a) { if (a == 0) return 1; long long t = pw(x, a / 2); if (a % 2 == 0) return (t * t); else return (t * t * x); } bool prime(int x) { if (x < 2) return false; for (int i = 2; i <= sqrt(x); i++) { if ((x % i) == 0) return false; } return true; } vector<pair<long long, long long> > a; map<int, long long> m; string ans; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; for (int i = 0; i < n; i++) { long long x; cin >> x; a.push_back({x, i}); } sort(a.begin(), a.end()); long long f = a[0].first; m[a[0].second] = f; f++; for (int i = 1; i < n; i++) { f = max(f, a[i].first); m[a[i].second] = f; f++; } for (int i = 0; i < n; i++) { cout << m[i] << ' '; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; inline long long pw(long long a, long long b) { return (b) ? (pw((a) * (a), (b) >> 1) * ((b)&1 ? (a) : 1)) : 1; } const int MAXN = 1e6 + 5; const long long INF = 1e10; const int MOD = 1e9 + 7; pair<long long, int> a[MAXN]; long long cur = -1; int main() { int n; cin >> n; vector<long long> ans(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++) { a[i].first = max(cur + 1, a[i].first); cur = a[i].first; ans[a[i].second] = a[i].first; } for (int i = 0; i < n; i++) cout << ans[i] << " "; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<pair<int, int> > a(n); for (int _n(n), i(0); i < _n; i++) cin >> a[i].first, a[i].second = i; vector<int> b(n); sort((a).begin(), (a).end()); int rnk = 0; for (int _n(n), i(0); i < _n; i++) { rnk = max(rnk + 1, a[i].first); b[a[i].second] = rnk; } for (int _n(n), i(0); i < _n; i++) cout << b[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> a[300000 + 13]; int n; void erf() { for (int i = 1; i < n; i++) { if (a[i - 1].first + 1 >= a[i].first) a[i].first = a[i - 1].first + 1; } } int main() { int cur, ebte; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); erf(); pair<int, int> b; for (int i = 0; i < n; i++) { b = make_pair(a[i].second, a[i].first); swap(a[i], b); } sort(a, a + n); for (int i = 0; i < n; i++) { cout << a[i].second << " "; } cout << endl; }
#include <bits/stdc++.h> using namespace std; long long arr[3 * 100001]; long long res[3 * 100001]; map<long long, long long> M; struct Z { long long n; int ind; Z() {} Z(long long a, int b) { n = a; ind = b; } bool operator<(const Z& A) const { return A.n > n; } }; vector<Z> V; int main() { int i, j; int a, b; int n; cin >> n; V.clear(); for (i = 0; i < n; i++) { cin >> arr[i]; V.push_back(Z(arr[i], i)); } sort(V.begin(), V.end()); long long mx = 0; for (i = 0; i < n; i++) { long long cn = V[i].n; int ind = V[i].ind; mx = max(cn, mx); res[ind] = mx; mx++; } for (i = 0; i < n; i++) cout << res[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { vector<pair<int, int> > vec(n); for (int i = 0; i < n; i++) { cin >> vec[i].first; vec[i].second = i; } sort(vec.begin(), vec.end()); for (int i = 1; i < n; i++) { if (vec[i].first <= vec[i - 1].first) vec[i].first = vec[i - 1].first + 1; } vector<int> res(n); for (int i = 0; i < n; i++) res[vec[i].second] = vec[i].first; for (int i = 0; i < n - 1; i++) cout << res[i] << " "; cout << res[n - 1] << endl; } }
#include <bits/stdc++.h> using namespace std; pair<int, int> a[300001]; int print[300001]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); for (int i = 1; i < n; i++) { if (a[i].first <= a[i - 1].first) { a[i].first = a[i - 1].first + 1; } } for (int i = 0; i < n; i++) print[a[i].second] = a[i].first; for (int i = 0; i < n; i++) cout << print[i] << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<long long, long> in[n]; pair<long long, long> out[n]; for (int i = 0; i < n; i++) { cin >> in[i].first; in[i].second = i + 1; } sort(in, in + n); out[0].first = in[0].second; out[0].second = in[0].first; for (int i = 1; i < n; i++) { if (in[i].first <= in[i - 1].first) in[i].first = in[i - 1].first + 1; out[i].first = in[i].second; out[i].second = in[i].first; } sort(out, out + n); for (int i = 0; i < n; i++) cout << out[i].second << " "; }
#include <bits/stdc++.h> using namespace std; int n, i, k; struct T { int id, val; } a[500000]; bool by_val(T x, T y) { if (x.val < y.val) return true; else return false; } bool by_id(T x, T y) { if (x.id < y.id) return true; else return false; } int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i].val; a[i].id = i; } sort(a, a + n + 1, &by_val); for (i = 2; i <= n; i++) { a[i].val = max(a[i - 1].val + 1, a[i].val); } sort(a, a + n + 1, &by_id); for (i = 1; i <= n; i++) { cout << a[i].val << " "; } }
#include <bits/stdc++.h> using namespace std; struct node { int p, id; } a[300001]; bool cmp(node a, node b) { return a.p < b.p; } bool comp(node a, node b) { return a.id < b.id; } int main() { int i, n; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i].p; a[i].id = i; } sort(a + 1, a + n + 1, cmp); int Min = a[1].p; for (i = 1; i <= n; i++) { if (a[i].p <= Min) { a[i].p = Min++; } else Min = a[i].p + 1; } sort(a + 1, a + n + 1, comp); cout << a[1].p; for (i = 2; i <= n; i++) cout << " " << a[i].p; }
#include <bits/stdc++.h> using namespace std; int n, ans[300005]; struct odp { int x, id; bool operator<(const odp &T) const { return x < T.x; } } a[300005]; int main() { scanf("%d", &n); for (int i = (0); i < (n); i++) { a[i].id = i; scanf("%d", &a[i].x); } sort(a, a + n); int dp = -1; for (int i = (0); i < (n); i++) { dp = max(dp, a[i].x); ans[a[i].id] = dp; dp++; } for (int i = (0); i < (n); i++) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' '); scanf("\n"); }
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int> > vec; int main() { std::ios::sync_with_stdio(false); long long int n, a; cin >> n; long long int arr[n]; for (long long int i = 0; i < n; i++) { cin >> a; vec.push_back(make_pair(a, i)); } sort(vec.begin(), vec.end()); for (long long int i = 1; i < n; i++) { if (vec[i].first <= vec[i - 1].first) vec[i].first = vec[i - 1].first + 1; } for (long long int i = 0; i < n; i++) { arr[vec[i].second] = vec[i].first; } for (long long int i = 0; i < n; i++) { cout << arr[i] << " "; } }
#include <bits/stdc++.h> using namespace std; const long long INF = 100000000000000000; const long long MOD = 1000000007; const long long MAXN = 100005; long long dx[] = {0, 0, -1, 1, -1, -1, 1, 1}; long long dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; void solve() { long long n; cin >> n; long long a[n], ans[n]; pair<long long, long long> b[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; b[i].first = a[i]; b[i].second = i; } sort(b, b + n); long long now = -1; for (int i = 0; i < n; ++i) { if (b[i].first > now) { now = b[i].first; } ans[b[i].second] = now; now += 1; } for (int i = 0; i < n; ++i) { cout << ans[i] << " "; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> a[300000]; int main() { int i, j, n, b[300000], ok = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i].first; a[i].second = i; } sort(a + 1, a + n + 1); for (i = 1; i <= n; i++) { ok = max(a[i].first, ok + 1); b[a[i].second] = ok; } for (i = 1; i <= n; i++) { cout << b[i] << ' '; } return 0; }
#include <bits/stdc++.h> using namespace std; struct p { int val; int index; }; bool cmp(p x, p y) { return x.val < y.val; } vector<p> v; int n; void debug() { for (int i = 0; i < v.size(); i++) { cout << v[i].val << " "; } cout << endl; } map<int, int> myMap; int main() { cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; myMap.insert(std::pair<int, int>(i, x)); p k; k.val = x; k.index = i; v.push_back(k); } sort(v.begin(), v.end(), cmp); int maxUsed = 0; for (int i = 0; i < n; i++) { int val = max(v[i].val, maxUsed + 1); if (val > maxUsed) maxUsed = val; myMap[v[i].index] = val; } for (int i = 0; i < n; i++) { cout << myMap[i] << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, x; pair<int, int> p[3000002]; map<int, int> m; int main() { int i, j, num; cin >> n; for (i = 1; i < n + 1; i++) { cin >> num, p[i].first = num, p[i].second = i, m[i] = num; } sort(p + 1, p + n + 1); for (i = 1; i < n + 1; i++) { if (p[i].first <= p[i - 1].first) { m[p[i].second] += ((p[i - 1].first - p[i].first) + 1), p[i].first += ((p[i - 1].first - p[i].first) + 1); } } i = 1; while (i != n) cout << m[i++] << " "; cout << m[n] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; pair<int, int> a[N]; int ans[N]; signed main() { ios_base::sync_with_stdio(0); cin.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 + n + 1); for (int i = 1; i <= n; ++i) { a[i].first = max(a[i].first, a[i - 1].first); if (a[i].first == a[i - 1].first) a[i].first++; } for (int i = 1; i <= n; ++i) ans[a[i].second] = a[i].first; for (int i = 1; i <= n; ++i) cout << ans[i] << ' '; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 300100; struct coso { long long val, ind, ans; }; bool val(coso a, coso b) { return a.val < b.val; } bool ind(coso a, coso b) { return a.ind < b.ind; } long long n; coso a[MAXN]; int main() { cin >> n; for (int i = 0; i < (int)(n); i++) { cin >> a[i].val; a[i].ind = i + 1; } sort(a, a + n, val); long long act = 0; for (int i = 0; i < (int)(n); i++) { a[i].ans = max(a[i].val, act); act = a[i].ans + 1; } sort(a, a + n, ind); for (int i = 0; i < (int)(n); i++) { if (i) cout << " "; cout << a[i].ans; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { 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()); vector<pair<int, int>> b(n); for (int i = 1; i < n; i++) if (a[i].first <= a[i - 1].first) a[i].first = a[i - 1].first + 1; for (int i = 0; i < n; i++) { b[i].first = a[i].second; b[i].second = a[i].first; } sort(b.begin(), b.end()); for (int i = 0; i < n; i++) cout << b[i].second << ' '; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 500000; struct gift { int a, id; } b[N]; map<int, int> m; int n, i, ans[N], last; bool cmp(gift A, gift B) { return A.a < B.a; } int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &b[i].a); b[i].id = i; } sort(b + 1, b + n + 1, &cmp); for (i = 1; i <= n; i++) { if (b[i].a < last) b[i].a = last; while (m[b[i].a] == 1) b[i].a++; m[b[i].a] = 1; ans[b[i].id] = b[i].a; last = b[i].a; } for (i = 1; i <= n; i++) printf("%d ", ans[i]); return 0; }
#include <bits/stdc++.h> using namespace std; long long arr[3 * 100001]; long long res[3 * 100001]; map<long long, long long> M; inline long long rec(long long n) { if (!M[n]) return n; return rec(M[n] + 1); } int main() { int i, j; int a, b; int n; cin >> n; for (i = 0; i < n; i++) { cin >> arr[i]; } for (i = 0; i < n; i++) { long long cn = arr[i]; if (!M[cn]) { M[cn] = cn + 1; res[i] = cn + 1; } else { long long num = M[arr[i]]; long long cn = arr[i]; long long tmp = arr[i]; vector<long long> V; V.clear(); while (cn <= (tmp + 3 * 100000)) { long long mp = M[cn]; if (!M[mp]) { V.push_back(mp); break; } V.push_back(cn); cn = mp; } int sz = V.size(); for (j = 0; j < sz; j++) M[V[j]] = V[sz - 1] + 1; res[i] = V[sz - 1] + 1; } } for (i = 0; i < n; i++) cout << res[i] - 1 << " "; M.clear(); return 0; }
#include <bits/stdc++.h> using namespace std; struct st { int p, a, b; }; int compare1(const void *a, const void *b) { return ((*(struct st *)a).a - (*(struct st *)b).a); } int compare2(const void *a, const void *b) { return ((*(struct st *)a).p - (*(struct st *)b).p); } int main() { int n, i; scanf("%d", &n); struct st c[n]; for (i = 0; i < n; i++) { scanf("%d", &c[i].a); c[i].p = i; } qsort(c, n, sizeof(c[0]), compare1); c[0].b = c[0].a; for (i = 1; i < n; i++) { c[i].b = max(1 + c[i - 1].b, c[i].a); } qsort(c, n, sizeof(c[0]), compare2); printf("%d", c[0].b); for (i = 1; i < n; i++) { printf(" %d", c[i].b); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; typedef struct person { int m; int r; int pos; } person; int compare1(const void *a, const void *b) { int x = ((person *)a)->m; int y = ((person *)b)->m; return x - y; } int compare2(const void *a, const void *b) { int x = ((person *)a)->pos; int y = ((person *)b)->pos; return x - y; } int main() { int n; cin >> n; person *p = new person[n]; for (int i = 0; i < n; i++) { cin >> p[i].m; p[i].pos = i; } qsort(p, n, sizeof(person), compare1); int newr = p[0].m; p[0].r = newr; newr++; for (int i = 1; i < n; i++) { int r1 = p[i - 1].m; int r2 = p[i].m; if (r2 > r1) { newr = r2; } p[i].r = p[i].m = newr; newr++; } qsort(p, n, sizeof(person), compare2); for (int i = 0; i < n; i++) { cout << p[i].r << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 3 * 1e5 + 10; struct visiter { int index, want, get; }; vector<visiter> vis; bool cmp1(visiter v1, visiter v2) { return v1.index < v2.index; } bool cmp2(visiter v1, visiter v2) { return v1.want < v2.want; } int main(void) { int n; cin >> n; vis.resize(n); for (int i = 0; i < n; i++) { vis[i].index = i; cin >> vis[i].want; } sort(vis.begin(), vis.end(), cmp2); int cur = 1; for (int i = 0; i < n; i++) { cur = max(cur, vis[i].want); vis[i].get = cur; cur++; } sort(vis.begin(), vis.end(), cmp1); for (int i = 0; i < n; i++) { cout << vis[i].get << ((i == n - 1) ? '\n' : ' '); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 3 * 1e5 + 5; long long n, now = 1; long long b[N]; struct myt { long long a, id; } cus[N]; bool cmp(myt a, myt b) { return a.a < b.a; } long long read() { long long s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = (s << 3) + (s << 1) + ch - '0', ch = getchar(); return s * w; } signed main() { n = read(); for (long long i = 1; i <= n; ++i) cus[i].a = read(), cus[i].id = i; sort(cus + 1, cus + 1 + n, cmp); for (long long i = 1; i <= n; ++i) { if (cus[i].a > now) now = cus[i].a, b[cus[i].id] = now, ++now; else b[cus[i].id] = now, ++now; } for (long long i = 1; i <= n; ++i) printf("%lld ", b[i]); return 0; }
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > num; vector<pair<int, int> > ans; int main() { int n; cin >> n; int c; for (int i = 0; i < n; i++) { cin >> c; num.push_back(make_pair(c, i)); } sort(num.begin(), num.end()); ans.push_back(make_pair(num[0].second, num[0].first)); for (int i = 1; i < n; i++) { int d = max(ans[i - 1].second + 1, num[i].first); ans.push_back(make_pair(num[i].second, d)); } sort(ans.begin(), ans.end()); for (int i = 0; i < n; i++) { cout << ans[i].second << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); int dblcmp(double d) { if (fabs(d) < eps) return 0; return d > eps ? 1 : -1; } int n, b[333333]; set<int> st; pair<int, int> a[333333]; int main() { int i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i].first); a[i].second = i; } sort(a, a + n); b[a[0].second] = a[0].first; st.insert(a[0].first); for (i = 1; i < n; i++) { if (st.find(a[i].first) == st.end()) { b[a[i].second] = a[i].first; st.insert(a[i].first); } else { b[a[i].second] = a[i - 1].first + 1; st.insert(a[i - 1].first + 1); a[i].first = a[i - 1].first + 1; } } for (i = 0; i < n; i++) printf("%d ", b[i]); puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<pair<long long, long long> > v, w; for (long long i = 0; i < n; ++i) { long long a; cin >> a; v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); long long p = 0; for (long long i = 0; i < n; ++i) { p = max(p, v[i].first); w.push_back(make_pair(v[i].second, p)); p++; } sort(w.begin(), w.end()); cout << w[0].second; for (long long i = 1; i < n; ++i) { cout << " " << w[i].second; } cout << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using PII = pair<int, int>; using LL = long long; const int INF = 1000000007; PII a[300005]; int c[300005]; int main() { int n, x = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i].first); a[i].second = i; } sort(a, a + n); for (int i = 0; i < n; i++) { x = max(x + 1, a[i].first); c[a[i].second] = x; } for (int i = 0; i < n - 1; i++) printf("%d ", c[i]); printf("%d\n", c[n - 1]); }
#include <bits/stdc++.h> using namespace std; long long i, j, mxa = 1e15, mxb = 1e15, r, e, t, n, a[300001], q; pair<long long, long long> p[300001]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; p[i] = make_pair(a[i], i); } sort(p + 1, p + 1 + n); t = 0; for (i = 1; i <= n; i++) { t++; q = p[i].first; if (q > t) t = q; a[p[i].second] = t; } for (i = 1; i <= n; i++) cout << a[i] << " "; }
#include <bits/stdc++.h> using namespace std; int A[3 * 100666], ind[3 * 100666]; long long result[3 * 100666]; long long lval; int n, i; bool comp(int i1, int i2) { return A[i1] < A[i2]; } int main() { cin >> n; for (i = 1; i <= n; ++i) { cin >> A[i]; ind[i] = i; } sort(ind + 1, ind + n + 1, comp); for (i = 1; i <= n; ++i) { long long V = A[ind[i]]; result[ind[i]] = max(lval + (long long)1, V); lval = max(lval + 1, V); } for (i = 1; i <= n; ++i) cout << result[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int ans[300005], x, previ, n; vector<pair<int, int> > b; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; b.push_back(make_pair(x, i)); } sort(b.begin(), b.end()); previ = b[0].first; ans[b[0].second] = previ; for (int i = 1; i < n; i++) { if (previ < b[i].first) { previ = b[i].first; ans[b[i].second] = previ; } else { previ++; ans[b[i].second] = previ; } } for (int i = 0; i < n; i++) cout << ans[i] << " "; }
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > vec; map<long long, long long> mp; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, a; string str = " "; cin >> n; for (int i = 0; i < n; i++) { cin >> a; vec.push_back(make_pair(a, i)); } sort(vec.begin(), vec.end()); long long temp = vec[0].first; for (int i = 1; i < n; i++) { if (vec[i - 1].first == vec[i].first) { vec[i].first++; temp = vec[i].first; } else if (vec[i].first <= temp) { vec[i].first = temp + 1; temp++; } else temp = vec[i].first; } for (int i = 0; i < n; i++) { mp[vec[i].second] = vec[i].first; } for (int i = 0; i < n; i++) { cout << mp[i] << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int siz = 3e5 + 5; int n, m, a[siz], out[siz]; set<long long> s; bool is_ok(long long num) { if (s.find(num) == s.end()) return true; return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; vector<pair<long long, long long> > v; for (int i = 1; i <= n; i++) { int x; cin >> x; v.push_back({x, i}); } sort(v.begin(), v.end()); int sofar = 0; for (int i = 0; i < v.size(); i++) { int cur = v[i].first, ind = v[i].second; if (cur > sofar) { sofar = cur; out[ind] = sofar; } else { out[ind] = ++sofar; } } for (long long i = 1; i <= n; i++) cout << out[i] << " "; }
#include <bits/stdc++.h> using namespace std; const long long nax = 3e5 + 100; pair<long long, long long> a[nax]; long long n, res[nax]; signed main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); long long cur = 0; for (long long i = 0; i < n; i++) { a[i].first = max(a[i].first, cur + 1); cur = a[i].first; res[a[i].second] = a[i].first; } for (long long i = 0; i < n; i++) cout << res[i] << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i; int a[300000], ans[300000]; vector<vector<int> > b; for (i = 0; i < n; i++) { cin >> a[i]; vector<int> x; x.push_back(a[i]); x.push_back(i); b.push_back(x); } sort(b.begin(), b.end()); int m = 1; for (i = 0; i < n; i++) { if (b[i][0] < m) { ans[b[i][1]] = m; m += 1; } else { ans[b[i][1]] = b[i][0]; m = b[i][0] + 1; } } for (i = 0; i < n; i++) cout << ans[i] << ' '; return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, a, j = 0, kh[300009]; pair<int, int> p[300009]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; p[i].first = x; p[i].second = i; } sort(p, p + n); for (int i = 0; i < n; i++) { j = max(j, p[i].first); kh[p[i].second] = j; j++; } for (int i = 0; i < n; i++) cout << kh[i] << " "; }
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T& first) { return first * first; } template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795L; const double EPS = 1 - 9; char TEMPORARY_CHAR; const int INF = 1e9; inline void input(int& a) { a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')) { } char neg = 0; if (TEMPORARY_CHAR == '-') { neg = 1; TEMPORARY_CHAR = getchar(); } while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') { a = 10 * a + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar(); } if (neg) a = -a; } inline void out(int a) { if (!a) putchar('0'); if (a < 0) { putchar('-'); a = -a; } char s[10]; int i; for (i = 0; a; ++i) { s[i] = '0' + a % 10; a /= 10; } for (int j = (i)-1; j >= 0; j--) putchar(s[j]); } inline int nxt() { int(ret); input((ret)); ; return ret; } using namespace std; int main() { int(n); input((n)); ; pair<int, int> a[n]; for (int i = 0; i < n; ++i) { a[i].first = nxt(); a[i].second = i; } sort(a, a + n); int cur = 0; int ans[n]; for (int i = 0; i < n; ++i) { cur = max(cur + 1, a[i].first); ans[a[i].second] = cur; } for (int i = 0; i < n; ++i) { if (i) cout << " "; cout << ans[i]; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> x, pair<int, int> y) { return x.second < y.second; } int main() { int n; cin >> n; pair<int, int> a[n]; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } int x = 1; sort(a, a + n); for (int i = 0; i < n; i++) { if (a[i].first == x) x++; else if (a[i].first < x) { a[i].first = x; x++; } else x = a[i].first + 1; } sort(a, a + n, cmp); for (int i = 0; i < n; i++) { cout << a[i].first << " "; } }
#include <bits/stdc++.h> using namespace std; template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } long long modpow(long long base, long long expo, long long curMod) { long long ans = 1; base %= curMod; if (base == 0) return 0; while (expo) { if (expo % 2) ans = ans * base % curMod; expo /= 2; base = base * base % curMod; if (ans < 0) ans += curMod; if (base < 0) base += curMod; } return ans; } int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n; cin >> n; vector<pair<long long, long long> > a(n); for (auto(i) = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); vector<long long> ans(n); long long cur = -1e18 + 5; for (auto(i) = 0; i < n; i++) { cur = max(cur + 1, a[i].first); ans[a[i].second] = cur; } for (auto(i) = 0; i < n; i++) cout << ans[i] << ' '; cout << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; void read(int &x) { char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48; } int n, a[400000], b[400000], ans[400000]; inline bool cpr(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]), b[i] = i; sort(b + 1, b + n + 1, cpr); int t(0); for (int i = 1; i <= (n); ++i) { t = max(t + 1, a[b[i]]); ans[b[i]] = t; } for (int i = 1; i <= (n - 1); ++i) printf("%d ", ans[i]); printf("%d\n", ans[n]); return 0; }
#include <bits/stdc++.h> using namespace std; struct in { int neww, prev, pos; }; in info[300005]; bool cmp1(in x, in y) { return x.prev < y.prev; } bool cmp2(in x, in y) { return x.pos < y.pos; } bool bsrch(int low, int h, int x); int main() { int n, i, j, x; while ((scanf("%d", &n)) != EOF) { for (i = 0; i < n; i++) { scanf("%d", &info[i].prev); info[i].pos = i; } sort(info, info + n, cmp1); info[0].neww = info[0].prev; for (i = 1; i < n; i++) { if (info[i].prev <= info[i - 1].neww) info[i].neww = info[i - 1].neww + 1; else info[i].neww = info[i].prev; } sort(info, info + n, cmp2); printf("%d", info[0].neww); for (i = 1; i < n; i++) printf(" %d", info[i].neww); printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> inline T LCM(T a, T b) { if (a < 0) return LCM(-a, b); if (b < 0) return LCM(a, -b); return a * (b / gcd(a, b)); } set<int> s; int a[310000], b[310000]; vector<pair<int, int> > u, v; int main() { s.clear(); int i, j, n, ans, temp; scanf("%d", &n); u.clear(); v.clear(); for (i = (int)0; i < (int)n; ++i) { scanf("%d", &a[i]); u.push_back(make_pair(a[i], i)); } sort(u.begin(), u.end()); temp = 1; for (i = (int)0; i < (int)n; ++i) { if (temp < u[i].first) temp = u[i].first; v.push_back(make_pair(temp, u[i].second)); temp++; } for (i = (int)0; i < (int)n; ++i) b[v[i].second] = v[i].first; for (i = (int)0; i < (int)n; ++i) printf("%d ", b[i]); return 0; }
#include <bits/stdc++.h> using namespace std; inline bool isLow(char ch) { if (ch >= 'a' && ch <= 'z') return true; return false; } inline bool isUpp(char ch) { if (ch >= 'A' && ch <= 'Z') return true; return false; } inline bool isDig(char ch) { if (ch >= '0' && ch <= '9') return true; return false; } inline bool are_equal(double a, double b) { return fabs(a - b) < numeric_limits<double>::epsilon(); } inline bool greater_than(double a, double b) { return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * numeric_limits<double>::epsilon()); } inline bool less_than(double a, double b) { return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * numeric_limits<double>::epsilon()); } template <typename T> string toString(T x) { stringstream ss; ss << x; return ss.str(); } template <typename T> T SOD(T n) { __typeof(n) sum = 0, i = 1; for (; i * i <= n; i++) sum += (n % i) ? 0 : ((((i) * (i)) == n) ? i : i + n / i); return sum; } template <typename T> T stringToT(string s, T a) { T p; istringstream ss(s); ss >> p; return p; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); i++) { os << v[i]; if (i != (int)v.size() - 1) os << ", "; } os << "]"; return os; } template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { os << "["; for (auto it : v) { os << it; if (it != *v.rbegin()) os << ", "; } os << "]"; return os; } template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << " : " << it.second << '\n'; return os; } template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { os << "(" << v.first << ", " << v.second << ")"; return os; } long long power(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res *= a; a = ((a) * (a)); b >>= 1; } return res; } long long bigmod(long long a, long long b, long long m) { long long res = 1; while (b) { if (b & 1) { res = ((res % m) * (a % m)) % m; } a = ((a % m) * (a % m)) % m; b >>= 1; } return res; } long long modInverse(long long a, long long m) { return bigmod(a, m - 2, m); } const int mod = 1e9 + 7; const int mx = 3 * 100001; int n; pair<int, int> a[mx]; bool sortbyidx(pair<int, int> x, pair<int, int> y) { return x.second < y.second; } int main() { scanf("%d", &n); for (__typeof(n - 1) i = (0); i <= (n - 1); i++) scanf("%d", &a[i]), a[i].second = i; sort(a, a + n); int sml = a[0].first; for (__typeof(n - 1) i = (1); i <= (n - 1); i++) { if (a[i].first == sml) { a[i].first++; sml++; } else if (a[i].first > sml) sml = a[i].first; else a[i].first = ++sml; } sort(a, a + n, sortbyidx); for (__typeof(n - 1) i = (0); i <= (n - 1); i++) printf("%d ", a[i].first); puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> p[300005]; int ans[300005]; int main() { int n, i, curr; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &p[i].first); p[i].second = i; } sort(p, p + n); curr = 0; for (i = 0; i < n; i++) { curr = max(curr + 1, p[i].first); ans[p[i].second] = curr; } for (i = 0; i < n; i++) printf("%d ", ans[i]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> a[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 = 1; i < n; ++i) { if (a[i].first == cur) { a[i].first = a[i - 1].first + 1; } else { cur = a[i].first; if (a[i].first <= a[i - 1].first) { a[i].first = a[i - 1].first + 1; } } } sort(a, a + n, [&](const pair<int, int> &l, const pair<int, int> &r) -> bool { return l.second < r.second; }); for (int i = 0; i < n; ++i) cout << a[i].first << " "; return !cout << '\n'; }
#include <bits/stdc++.h> using namespace std; struct presents { int number; int value; int rating; } User[300005]; bool comparison(struct presents a, struct presents b) { return a.value < b.value; } bool comparison2(struct presents a, struct presents b) { return a.number < b.number; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { User[i].number = i; scanf("%d", &User[i].value); } sort(User, User + n, comparison); for (int i = 0; i < n; i++) { if (i == 0 || User[i].value > User[i - 1].rating) { User[i].rating = User[i].value; } else { User[i].rating = User[i - 1].rating + 1; } } sort(User, User + n, comparison2); int i; for (i = 0; i < n - 1; i++) printf("%d ", User[i].rating); printf("%d\n", User[i].rating); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 300 * 1000 + 10, INF = INT_MAX, MOD = 1e9 + 7; pair<int, int> a[MAXN]; int ans[MAXN]; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i; sort(a, a + n); int mx = 0; for (int i = 0; i < n; i++) { if (i && a[i].first == a[i - 1].first) ans[a[i].second] = ans[a[i - 1].second] + 1; else ans[a[i].second] = max(a[i].first, mx + 1); mx = max(mx, ans[a[i].second]); } for (int i = 0; i < n; i++) cout << ans[i] << ' '; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, i, now, a[300010]; struct node { long long val, x; }; node arr[300010]; bool comp1(node a, node b) { return a.val < b.val; } bool comp2(node a, node b) { return a.x < b.x; } int main() { scanf(" %I64d", &n); for (i = 0; i < n; i++) { scanf(" %I64d", &arr[i].val); a[i] = arr[i].val; arr[i].x = i; } sort(arr, arr + n, comp1); now = arr[0].val; for (i = 0; i < n; now++, i++) { if (arr[i].val <= now) a[arr[i].x] = now; else { now = arr[i].val; } } for (i = 0; i < n; i++) { printf("%I64d ", a[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int N; vector<int> A; vector<int> S; bool comp(int a, int b) { return A[a] < A[b]; } int main() { cin >> N; A.resize(N); S.resize(N); for (int i = 0; i < N; i++) cin >> A[i], S[i] = i; sort(S.begin(), S.end(), comp); long long rat = 0; vector<long long> ans(N); for (int i = 0; i < N; i++) { rat = max(rat + 1, (long long)A[S[i]]); ans[S[i]] = rat; } for (int i = 0; i < N; i++) cout << ans[i] << " "; cout << endl; }
#include <bits/stdc++.h> using namespace std; struct node { int v, u; } p[1000000]; bool cmp1(const node x, const node y) { return x.v < y.v; } bool cmp2(const node x, const node y) { return x.u < y.u; } int main() { int n; while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) { scanf("%d", &p[i].v); p[i].u = i; } sort(p + 1, p + n + 1, cmp1); int t = p[1].v; for (int i = 2; i <= n; i++) { if (p[i].v > t) t = p[i].v; else t++; p[i].v = t; } sort(p + 1, p + n + 1, cmp2); printf("%d", p[1].v); for (int i = 2; i <= n; i++) printf(" %d", p[i].v); printf("\n"); } return 0; }