text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { long long c1, c2, c3, c4, n, m, b[1005], t[1005], ans; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (long long i = 0; i < n; i++) cin >> b[i]; for (long long i = 0; i < m; i++) cin >> t[i]; long long temp1 = 0, temp2 = 0; for (long long i = 0; i < n; i++) temp1 += min(b[i] * c1, c2); temp1 = min(temp1, c3); for (long long i = 0; i < m; i++) temp2 += min(t[i] * c1, c2); temp2 = min(temp2, c3); ans = min(c4, temp1 + temp2); cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4, n, m, a[1002], b[1002], temp; bool bus = false, trolley = false; int minCost, cost12b = 0, cost12t = 0, cost3 = 0, minCost123b, minCost123t; cin >> c1 >> c2 >> c3 >> c4 >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; cost12b += min(a[i] * c1, c2); if (a[i] > 0) { bus = true; } } minCost123b = min(cost12b, c3); for (int i = 0; i < m; i++) { cin >> b[i]; cost12t += min(b[i] * c1, c2); if (b[i] > 0) { trolley = true; } } minCost123t = min(cost12t, c3); minCost = min(c4, minCost123t + minCost123b); cout << minCost << endl; return 0; }
#include <bits/stdc++.h> using namespace std; double pi = 3.1415926536; const int oo = (int)1e9; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int di[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dj[] = {1, -1, 0, 0, 1, -1, 1, -1}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4; int n, m; int sum = 0; cin >> n >> m; for (int i = 0; i < n; i++) { int x; cin >> x; if (x * c1 < c2) sum += x * c1; else sum += c2; } if (sum > c3) sum = c3; int sum2 = 0; for (int i = 0; i < m; i++) { int x; cin >> x; if (x * c1 < c2) sum2 += x * c1; else sum2 += c2; } if (sum2 > c3) sum2 = c3; sum += sum2; cout << min(sum, c4); }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c1, c2, c3, c4, bus = 0, tbus = 0, temp; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> temp; if (temp * c1 < c2) bus += temp * c1; else bus += c2; } bus = min(bus, c3); for (int i = 0; i < m; i++) { cin >> temp; if (temp * c1 < c2) tbus += temp * c1; else tbus += c2; } tbus = min(tbus, c3); cout << min(bus + tbus, c4); return 0; }
#include <bits/stdc++.h> using namespace std; int c1, c2, c3, c4; int solve(int a[], int s) { int ans = 0; for (int i = 0; i < s; i++) { ans = ans + min(c2, a[i] * c1); } return min(c3, ans); } int main() { int m, n; cin >> c1 >> c2 >> c3 >> c4 >> n >> m; int T[n], B[m]; for (int i = 0; i < n; i++) cin >> T[i]; for (int i = 0; i < m; i++) cin >> B[i]; int ans = min(c4, solve(T, n) + solve(B, m)); cout << ans; return 0; }
#include <bits/stdc++.h> int n, m, s1, s2, c1, c2, c3, c4, x; int main() { scanf("%d%d%d%d%d%d", &c1, &c2, &c3, &c4, &n, &m); for (int i = 0; i < n; i++) { scanf("%d", &x); s1 += (c1 * x < c2 ? c1 * x : c2); } for (int i = 0; i < m; i++) { scanf("%d", &x); s2 += (c1 * x < c2 ? c1 * x : c2); } s1 = (s1 < c3 ? s1 : c3); s2 = (s2 < c3 ? s2 : c3); printf("%d\n", (s1 + s2 < c4 ? s1 + s2 : c4)); }
#include <bits/stdc++.h> int main() { int i, c1, c2, c3, c4, n, m, a[1005], b[1005], a1[1005], b1[1005], sum1 = 0, sum2 = 0, total; scanf("%d%d%d%d%d%d", &c1, &c2, &c3, &c4, &n, &m); for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < m; i++) scanf("%d", &b[i]); for (i = 0; i < n; i++) { if (a[i] * c1 < c2) a1[i] = a[i] * c1; else a1[i] = c2; sum1 += a1[i]; } for (i = 0; i < m; i++) { if (b[i] * c1 < c2) b1[i] = b[i] * c1; else b1[i] = c2; sum2 += b1[i]; } if (sum1 > c3) sum1 = c3; if (sum2 > c3) sum2 = c3; if (sum1 + sum2 > c4) total = c4; else total = sum1 + sum2; printf("%d\n", total); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4, n, m; cin >> c1 >> c2 >> c3 >> c4 >> n >> m; int a = 0, b = 0; for (int i = 0; i < n; i++) { int x; cin >> x; a += min(x * c1, c2); } for (int i = 0; i < m; i++) { int x; cin >> x; b += min(x * c1, c2); } a = min(a, c3); b = min(b, c3); cout << min(a + b, c4); }
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4, n, m, a[1005], b[1005], sum = 0, ans; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; sum += b[i]; } int ans1 = 0, ans2 = 0; for (int i = 0; i < n; i++) { int temp = a[i]; int min1 = min(a[i] * c1, c2); ans1 += min1; } for (int i = 0; i < m; i++) { int temp = b[i]; int min1 = min(b[i] * c1, c2); ans2 += min1; } int ne1 = min(ans1, c3); int ne2 = min(ans2, c3); ans = min((ne1 + ne2), c4); cout << ans << endl; return 0; }
#include <bits/stdc++.h> int main(void) { int c[4]; int bus[1005]; int busall; int tr[1005]; int trall; int bt[1005]; int tt[1005]; int n, m; int i, j; for (i = 0; i < 4; i++) scanf("%d", &c[i]); scanf("%d %d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &bt[i]); for (i = 0; i < m; i++) scanf("%d", &tt[i]); busall = 0; trall = 0; for (j = 0; j < n; j++) { bus[j] = c[0] * bt[j]; busall += bus[j]; } for (j = 0; j < m; j++) { tr[j] = c[0] * tt[j]; trall += tr[j]; } for (j = 0; j < n; j++) { if (c[1] < bus[j]) { busall += c[1] - bus[j]; bus[j] = c[1]; } } for (j = 0; j < m; j++) { if (c[1] < tr[j]) { trall += c[1] - tr[j]; tr[j] = c[1]; } } if (busall > c[2]) busall = c[2]; if (trall > c[2]) trall = c[2]; int tall = busall + trall; if (tall > c[3]) tall = c[3]; printf("%d\n", tall); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4; int n, m; cin >> n >> m; long long sm = 0; long long tot = 0; for (int i = 0; i < n; i++) { int x = 0; cin >> x; tot += min(c1 * x, c2); sm += x; } tot = min(tot, c3); long long tot2 = 0; for (int i = 0; i < m; i++) { int x = 0; cin >> x; tot2 += min(c1 * x, c2); } tot2 = min(tot2, c3); cout << min(tot + tot2, c4) << endl; }
#include <bits/stdc++.h> int main() { int c1, c2, c3, c4; int a, b; scanf("%d%d%d%d", &c1, &c2, &c3, &c4); int m, n; scanf("%d%d", &m, &n); int s1 = 0, s2 = 0, s3 = 0, s4 = 0; int s = 0, ss = 0; for (int i = 0; i < m; i++) { scanf("%d", &a); if (c1 * a < c2) s1 += c1 * a; else s1 += c2; } if (s1 < c3) s = s1; else s = c3; for (int i = 0; i < n; i++) { scanf("%d", &b); if (c1 * b < c2) s2 += c1 * b; else s2 += c2; } int ans = 0; if (s2 < c3) ss = s2; else ss = c3; ans = s + ss; if (ans > c4) ans = c4; printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int fn(int a[], int l, int c1, int c2, int c3) { int i, res = 0; for (i = 0; i < l; i++) res += min(c1 * a[i], c2); return min(res, c3); } int main() { int c1, c2, c3, c4, m, n; cin >> c1 >> c2 >> c3 >> c4 >> n >> m; int b[n], t[m], i; for (i = 0; i < n; i++) cin >> b[i]; for (i = 0; i < m; i++) cin >> t[i]; cout << min(c4, fn(b, n, c1, c2, c3) + fn(t, m, c1, c2, c3)); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4, n, m; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; int* an = new int[n]; int* am = new int[m]; int sum_n = 0, sum_m = 0; for (int i = 0; i < n; i++) { cin >> an[i]; if (an[i] * c1 < c2) an[i] = an[i] * c1; else an[i] = c2; sum_n += an[i]; } for (int i = 0; i < m; i++) { cin >> am[i]; if (am[i] * c1 < c2) am[i] = am[i] * c1; else am[i] = c2; sum_m += am[i]; } int t1, t2; if (sum_n < c3) t1 = sum_n; else t1 = c3; if (sum_m < c3) t2 = sum_m; else t2 = c3; if (t1 + t2 < c4) cout << t1 + t2; else cout << c4; return 0; }
#include <bits/stdc++.h> using namespace std; long long bus[1001]; long long t[1001]; int main() { long long a, b, c, d, n, m; cin >> a >> b >> c >> d; long long ans = d; cin >> n >> m; long long maj = 0; long long tedbus = 0; long long tedt = 0; for (int i = 1; i <= n; i++) { cin >> bus[i]; long long u = min(bus[i] * a, b); tedbus += u; } tedbus = min(tedbus, c); for (int i = 1; i <= m; i++) { cin >> t[i]; long long u = min(t[i] * a, b); tedt += u; } tedt = min(tedt, c); maj = tedbus + tedt; ans = min(ans, maj); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4; int i, n, m, s1 = 0, s2 = 0, x; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (i = 0; i < n; ++i) { cin >> x; s1 += min(c2, x * c1); } s1 = min(s1, c3); for (i = 0; i < m; ++i) { cin >> x; s2 += min(x * c1, c2); } s2 = min(s2, c3); cout << min(s1 + s2, c4); return 0; }
#include <bits/stdc++.h> using namespace std; const int MX = 25; int main(int argc, char *argv[]) { int n; cin >> n; pair<int, int> a[n]; for (int i = (0), _b = (n); i < (_b); ++i) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); int ans[n]; int cur = 0; for (int i = (0), _b = (n); i < (_b); ++i) { if (cur < a[i].first) cur = a[i].first; ans[a[i].second] = cur++; } for (int i = (0), _b = (n); i < (_b); ++i) cout << ans[i] << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n; map<int, vector<int> > m; for (int i = 0; i < n; ++i) cin >> a, m[a].push_back(i); vector<int> ans(n); int v = m.begin()->first; for (map<int, vector<int> >::iterator i = m.begin(); i != m.end(); ++i) { v = max(v, i->first); while (i->second.size() > 1) { for (;; ++v) if (m.find(v) == m.end()) { m[v].push_back(i->second.back()); break; } i->second.pop_back(); } ans[i->second.back()] = i->first; } for (int i = 0; i < n; ++i) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; map<int, int> ma; int next(int x) { if (ma.find(x) == ma.end()) return x; return ma[x] = next(ma[x]); } int main() { int n, a; int i, j; cin >> n; for (i = 0; i < n; i++) { cin >> a; a = next(a); ma[a] = a + 1; if (i) cout << " "; cout << a; } return 0; }
#include <bits/stdc++.h> using namespace std; int maxnum(int a, int b) { if (a > b) return a; else return b; } int main() { int N; scanf("%d", &N); static pair<int, int> a[300005]; int i; for (i = 0; i < N; i++) { scanf("%d", &(a[i].first)); a[i].second = i; } sort(a, a + N); for (i = 1; i < N; i++) { a[i].first = maxnum(a[i - 1].first + 1, a[i].first); } for (i = 0; i < N; i++) { int temp = a[i].first; a[i].first = a[i].second; a[i].second = temp; } sort(a, a + N); for (i = 0; i < N; i++) { if (i) printf(" "); printf("%d", a[i].second); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; long int a[n], b[n]; for (i = 0; i < n; i++) { cin >> a[i]; b[i] = i; } vector<pair<long int, long int> > V; vector<pair<long int, long int> > W; for (i = 0; i < n; i++) V.push_back(make_pair(a[i], b[i])); sort(V.begin(), V.end()); for (i = 0; i < n; i++) { a[i] = V[i].first; b[i] = V[i].second; } for (i = 1; i < n; i++) { if (a[i] <= a[i - 1]) a[i] = a[i - 1] + 1; } for (i = 0; i < n; i++) W.push_back(make_pair(b[i], a[i])); sort(W.begin(), W.end()); for (i = 0; i < n; i++) cout << W[i].second << " "; return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> p[300000 + 100]; int res[300000 + 100]; bool Cmp(pair<int, int> A, pair<int, int> B) { return A.first < B.first; } int main() { ios_base::sync_with_stdio(0); int n, maX = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> p[i].first; p[i].second = i; } sort(p, p + n, Cmp); for (int i = 0; i < n; i++) { maX = max(maX + 1, p[i].first); res[p[i].second] = maX; } for (int i = 0; i < n; i++) cout << res[i] << " "; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3e5 + 35; int n, sol[MAX_N]; pair<int, int> a[MAX_N]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); int last = 0; for (int i = 0; i < n; i++) { if (a[i].first <= last) { a[i].first = last + 1; } last = a[i].first; sol[a[i].second] = a[i].first; } for (int i = 0; i < n; i++) { cout << sol[i] << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; pair<long long, long long> A[300005]; long long B[300005]; int main() { long long n; scanf("%lld", &n); for (long long i = 1; i <= n; ++i) { scanf("%lld", &A[i].first); A[i].second = i; } sort(A + 1, A + n + 1); long long val = 1; for (long long i = 1; i <= n; ++i) { val = max(val, A[i].first); B[A[i].second] = val; val++; } for (long long i = 1; i <= n; ++i) { printf("%lld ", B[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, cur; vector<pair<int, int> > v; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x); v.push_back(make_pair(x, i)); } sort(v.begin(), v.end()); for (int i = 0; i < n; i++) { if (v[i].first < cur) { v[i].first = cur; cur++; } else cur = v[i].first + 1; swap(v[i].first, v[i].second); } sort(v.begin(), v.end()); for (int i = 0; i < n; i++) { printf("%d", v[i].second); if (i == n - 1) printf("\n"); else printf(" "); } }
#include <bits/stdc++.h> using namespace std; const long long INF = 1ll * 1e13; const long long st = (1ll << 31); const long long MOD = 1000000007; const int NMAX = 2200000; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<pair<int, int> > a(n); map<int, int> m; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); int cur = 0; for (int i = 0; i < n; i++) { if (a[i].first > cur) cur = a[i].first + 1; else a[i].first = cur++; swap(a[i].first, a[i].second); } sort(a.begin(), a.end()); for (int i = 0; i < n; i++) cout << a[i].second << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, x, y, i, j; bool mark[300003]; vector<pair<int, int> > v; vector<pair<int, int> >::iterator it; vector<pair<int, int> > ans; vector<pair<int, int> > ans0; int main() { scanf("%d", &n); if (n == 1) { scanf("%d", &a); printf("%d\n", a); return 0; } for (i = 0; i < n; i++) { scanf("%d", &a); v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); for (i = 1; i < n; i++) { if (v[i].first == v[i - 1].first) mark[i] = true; } x = v[0].first + 1; for (i = 0; i < n; i++) { if (mark[i]) { x = max(x, v[i].first); it = lower_bound(v.begin(), v.end(), make_pair(x, 0)); if (it == v.end()) { ans.push_back(make_pair(x, v[i].second)); x++; } else { while ((*it).first == x) { x++; it = lower_bound(v.begin(), v.end(), make_pair(x, 0)); if (it == v.end()) { ans.push_back(make_pair(x, v[i].second)); x++; break; } } if (it != v.end()) { ans.push_back(make_pair(x, v[i].second)); x++; } } } else { ans.push_back(v[i]); } } for (i = 0; i < n; i++) { swap(ans[i].second, ans[i].first); } sort(ans.begin(), ans.end()); for (i = 0; i < n; i++) { printf("%d ", ans[i].second); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> inline string toString(T a) { ostringstream os(""); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <typename T> inline int toInt(T a) { int res; istringstream os(a); os >> res; return res; } template <typename T> inline double toDouble(T a) { double res; istringstream os(a); os >> res; return res; } template <typename T> inline T SQ(T a) { return a * a; } template <typename T> inline T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); } template <typename T> inline T LCM(T a, T b) { long long res = a * b; res /= GCD(a, b); return res; } template <typename T> inline unsigned long long BIGMOD(T a, T b, T m) { if (b == 0) return 1; else if (b % 2 == 0) return SQ(BIGMOD(a, b / 2, m)) % m; else return (a % m * BIGMOD(a, b - 1, m)) % m; } template <typename T> inline vector<string> PARSE(T str) { vector<string> res; string s; istringstream os(str); while (os >> s) res.push_back(s); return res; } template <typename T> inline unsigned long long DIST(T A, T B) { unsigned long long res = (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y); return res; } template <typename T> inline long long CROSS(T A, T B, T C) { return (B.x - A.x) * (C.y - A.y) - (C.x - A.x) * (B.y - A.y); } template <typename T> inline double cosAngle(T a, T b, T c) { double res = a * a + b * b - c * c; res = res / (2 * a * b); res = acos(res); return res; } template <typename T> inline T POWER(T base, int po) { T res = 1; if (base == 0) return 0; for (int i = (0); i < (po); i++) res *= base; return res; } template <typename T> inline bool IS_ON(T mask, T pos) { return mask & (1 << pos); } template <typename T> inline int OFF(T mask, T pos) { return mask ^ (1 << pos); } template <typename T> inline int ON(T mask, T pos) { return mask | (1 << pos); } template <typename T> inline bool INSIDE_GRID(int R, int C, int ro, int clm) { if (R >= 0 && C >= 0 && R < ro && C < clm) return 1; return 0; } template <typename T> inline void PRINT_GRID(T GRID, int ro, int clm) { cout << "GRID" << ": " << GRID << endl; for (int i = (0); i < (ro); i++) { for (int j = (0); j < (clm); j++) cout << GRID[i][j] << " "; puts(""); } } long long arr[500005]; vector<pair<long long, int> > inp; int main() { ios_base::sync_with_stdio(0); cin.tie(); ; int n; cin >> n; for (int i = (0); i < (n); i++) { cin >> arr[i]; inp.push_back(make_pair(arr[i], i)); } sort((inp).begin(), (inp).end()); long long hell = 0; for (int i = (0); i < (n); i++) { hell = max(inp[i].first, hell + 1); arr[inp[i].second] = hell; } for (int i = (0); i < (n); i++) cout << arr[i] << " "; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:64000000") using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int maxn = (int)3e5 + 10; int a[maxn], p[maxn]; bool cmp(int i, int j) { return a[i] < a[j]; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); p[i] = i; } sort(p, p + n, cmp); int mi = 1; for (int i = 0; i < n; i++) { int id = p[i]; mi = max(mi, a[id]); a[id] = mi; mi++; } for (int i = 0; i < n; i++) { printf("%d ", a[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> b[300001]; int ret[300001]; int main() { int n, val; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &val); b[i] = pair<int, int>(val, i); } sort(b, b + n); ret[b[0].second] = b[0].first; for (int i = 1; i < n; i++) { if (b[i - 1].first >= b[i].first) b[i].first = b[i - 1].first + 1; ret[b[i].second] = b[i].first; } for (int i = 0; i < n; i++) { printf("%d ", ret[i]); } puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; long int n; long int ans[511111]; long int cur; pair<long int, long int> p[511111]; int main() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; p[i] = make_pair(x, i); } sort(p + 1, p + 1 + n); for (int i = 1; i <= n; i++) { if (p[i].first > cur) { ans[p[i].second] = p[i].first; cur = p[i].first + 1; } else if (p[i].first <= cur) { ans[p[i].second] = cur; cur++; } } for (int i = 1; i <= n; i++) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; const int kMaxN = 300005; vector<pair<int, int> > ind; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { int el; cin >> el; ind.push_back(make_pair(el, i)); } sort(ind.begin(), ind.end()); for (int i = 0; i < n; ++i) { if (i and ind[i].first <= ind[i - 1].first) ind[i].first = ind[i - 1].first + 1; } for (int i = 0; i < n; ++i) swap(ind[i].first, ind[i].second); sort(ind.begin(), ind.end()); for (int i = 0; i < n; ++i) cout << ind[i].second << ' '; return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int n, a[333333]; int main() { while (cin >> n) { for (int i = (0); i < (n); i++) cin >> a[i]; vector<pair<int, int> > v; for (int i = (0); i < (n); i++) v.push_back(make_pair(a[i], i)); sort((v).begin(), (v).end()); v[0] = make_pair(v[0].second, v[0].first); for (int i = (1); i < (n); i++) { int b = v[i].first; ; if (v[i].first <= v[i - 1].second) b = v[i - 1].second + 1; v[i] = make_pair(v[i].second, b); } sort((v).begin(), (v).end()); for (int i = (0); i < (n); i++) cout << (i ? " " : "") << v[i].second; cout << endl; } }
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > vp; vector<int> v1(300005); int a[300005]; int main() { int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; vp.push_back({x, i + 1}); } sort(vp.begin(), vp.end()); int ha = vp[0].first, costo = 1; for (int i = 1; i < n; i++) { if (vp[i].first == ha) { vp[i].first += costo; costo++; } else { if (vp[i - 1].first >= vp[i].first) vp[i].first += 1 + vp[i - 1].first - vp[i].first; ha = vp[i].first; costo = 1; } } for (int i = 0; i < n; i++) { a[vp[i].second - 1] += vp[i].first; } for (int i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[400000], n, m, ans[400000]; map<int, int> mp; #pragma comment(linker, "/STACK:102400000,102400000") int find(int x) { if (mp[x] == 0) { if (mp[x + 1] == 0) mp[x] = x + 1; else mp[x] = find(x + 1); return x; } int t = find(mp[x]); mp[x] = t; return t; } int p[400000]; bool cmp(int i, int j) { return a[i] < a[j]; } int main() { while (cin >> n) { mp.clear(); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); p[i] = i; } sort(p, p + n, cmp); for (int i = 0; i < n; ++i) { m = p[i]; ans[m] = find(a[m]); } for (int i = 0; i < n; ++i) if (i == n - 1) printf("%d\n", ans[i]); else printf("%d ", ans[i]); } }
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int a, b, c, i, j, k, n, m, t, ar[1000001], ar2[1001][101], flag, p[1000][100], w[100001]; t = 1; char ch; while (t--) { pair<int, int> p; vector<pair<int, int> > v; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &ar[i]); p = make_pair(ar[i], i); v.push_back(p); } sort(v.begin(), v.end()); for (i = 1; i < n; i++) if (v[i - 1].first >= v[i].first) v[i].first = v[i - 1].first + 1; for (i = 0; i < n; i++) { a = v[i].second; ar[a] = v[i].first; } for (i = 1; i <= n; i++) printf("%d ", ar[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> a[3 * 100001]; int b[3 * 100001]; int main() { ios_base::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); for (int i = 0; i < n; i++) { if (i && a[i].first <= a[i - 1].first) a[i].first = a[i - 1].first + 1; b[a[i].second] = a[i].first; } for (int i = 0; i < n; i++) cout << b[i] << ' '; cout << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a[300005], i, b, p; vector<pair<int, int> > test; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &b); test.push_back(make_pair(b, i)); } sort(test.begin(), test.end()); p = -1; for (i = 0; i < n; i++) { if (test[i].first > p) p = test[i].first; a[test[i].second] = p; p++; } for (i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; struct A { int val; int pos; }; bool compv(const A& one, const A& two) { return one.val < two.val; } bool compp(const A& one, const A& two) { return one.pos < two.pos; } int main() { int n; cin >> n; A a[300002]; for (int i = 1; i <= n; ++i) { cin >> a[i].val; a[i].pos = i; } sort(a + 1, a + n + 1, compv); long long ans = 0; int cur_min = 0; for (int i = 1; i <= n; ++i) { if (a[i].val > cur_min) { cur_min = a[i].val; } else { cur_min++; a[i].val = cur_min; } } sort(a + 1, a + n + 1, compp); for (int i = 1; i <= n; ++i) cout << a[i].val << " "; cout << endl; }
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } void run() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } vector<pair<int, int> > v; pair<int, int> p; for (int i = 0; i < n; 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 != 0) { if (v[i].first <= v[i - 1].first) v[i].first = v[i - 1].first + 1; } } sort(v.begin(), v.end(), sortbysec); for (int i = 0; i < n; i++) { cout << v[i].first << " "; } } int main(int argc, char **argv) { run(); return 0; }
#include <bits/stdc++.h> using namespace std; int a[300005]; int ans[300005]; vector<pair<int, int> > v; int last = 0; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); v.push_back(make_pair(a[i], i)); } sort(v.begin(), v.end()); for (int i = 0; i < n; i++) { if (v[i].first <= last) { ans[v[i].second] = last + 1; last++; } else { ans[v[i].second] = v[i].first; last = v[i].first; } } printf("%d", ans[0]); for (int i = 1; i < n; i++) printf(" %d", ans[i]); puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; void jabru() { int n; cin >> n; vector<pair<int, int> > v(n); for (long long i = 0; i < n; i++) { int x; cin >> x; v[i] = make_pair(x, i); } sort(v.begin(), v.end()); vector<int> ans(n); int ind = v[0].first; for (long long i = 0; i < n; i++) { int x = v[i].first; ind = max(ind, x); ans[v[i].second] = ind; ind++; } for (long long i = 0; i < n; i++) cout << ans[i] << " "; cout << "\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); jabru(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); vector<pair<int, int> > v; int n, a; cin >> n; vector<int> ans(n, 0); for (int i = 0; i < n; i++) { cin >> a; v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); for (int i = 0; i < n; i++) { if (i > 0 && v[i].first <= v[i - 1].first) { v[i].first = v[i - 1].first + 1; } ans[v[i].second] = v[i].first; } for (int i = 0; i < n; i++) cout << ans[i] << " "; cout << endl; 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++) { scanf("%d", &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; typedef struct rate { int rt; int pos; } rate; bool func(rate a, rate b) { return a.rt < b.rt; } bool funcc(rate a, rate b) { return a.pos < b.pos; } int main() { int n; cin >> n; vector<rate> a(n); vector<rate> b(n); for (int i = 0; i < n; i++) { cin >> a[i].rt; a[i].pos = i; } sort(a.begin(), a.end(), func); int minpr = a[0].rt - 1; for (int i = 0; i < n; i++) { if (a[i].rt <= minpr) { b[i].rt = minpr + 1; b[i].pos = a[i].pos; minpr += 1; } else { b[i].rt = a[i].rt; b[i].pos = a[i].pos; minpr = a[i].rt; } } sort(b.begin(), b.end(), funcc); for (int i = 0; i < n; i++) cout << b[i].rt << " "; return 0; }
#include <bits/stdc++.h> using namespace std; pair<unsigned long long int, int> a[400000]; int mas[400000]; int main() { 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 = 2; i <= n; i++) { if (a[i - 1].first >= a[i].first) { a[i].first = a[i - 1].first + 1; } } for (int i = 1; i <= n; i++) { mas[a[i].second] = a[i].first; } for (int i = 1; i <= n; i++) { cout << mas[i] << ' '; } return 0; }
#include <bits/stdc++.h> using namespace std; bool compare1(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } bool compare2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } 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(), compare1); int u = a[0].first - 1; for (int i = 0; i < n; i++) { if (a[i].first == u) a[i].first = a[i - 1].first + 1; else if (i > 0 and a[i].first <= a[i - 1].first) a[i].first = a[i - 1].first + 1; else { a[i].first = a[i].first; u = a[i].first; } } sort(a.begin(), a.end(), compare2); for (int i = 0; i < n; i++) cout << a[i].first << " "; 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; const int N = 300006; pair<int, int> a[N]; int b[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); int c = 0; for (int i = 0; i < n; i++) { a[i].first = max(a[i].first, c + 1); c = a[i].first; b[a[i].second] = a[i].first; } for (int i = 0; i < n; i++) cout << b[i] << " "; }
#include <bits/stdc++.h> using namespace std; struct peo { int rating; int id; }; bool com(peo A, peo B) { return A.rating < B.rating; } int main() { int n; cin >> n; peo menber[n + 10]; int ans[n + 10], f[n + 10]; for (int i = 1; i <= n; i++) { cin >> menber[i].rating; menber[i].id = i; } sort(menber + 1, menber + n + 1, com); ans[0] = 0; for (int i = 1; i <= n; i++) ans[i] = max(ans[i - 1] + 1, menber[i].rating); for (int i = 1; i <= n; i++) f[menber[i].id] = ans[i]; for (int i = 1; i <= n; i++) cout << f[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b[300100], n; scanf("%d", &n); vector<pair<int, int> > v; for (int i = 0; i < n; i++) { scanf("%d", &a); v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); b[v[0].second] = v[0].first; for (int i = 1; i < n; i++) { b[v[i].second] = max(b[v[i - 1].second] + 1, v[i].first); } for (int i = 0; i < n; i++) printf("%d ", b[i]); return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 300005; struct node { int a, id; } g[maxn]; bool cmp1(node a, node b) { return a.a < b.a; } bool cmp2(node a, node b) { return a.id < b.id; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &g[i].a); g[i].id = i; } sort(g + 1, g + n + 1, cmp1); for (int i = 2; i <= n; i++) { if (g[i].a <= g[i - 1].a) { g[i].a = g[i - 1].a + 1; } } sort(g + 1, g + n + 1, cmp2); for (int i = 1; i <= n; i++) { if (i != 1) printf(" "); printf("%d", g[i].a); } return 0; }
#include <bits/stdc++.h> using std::sort; std::pair<int, int> all[300005]; inline bool cmp(std::pair<int, int> a, std::pair<int, int> b) { return a.second < b.second; } int main() { int n; while (~scanf("%d", &n)) { for (int i = 0; i < n; ++i) scanf("%d", &all[i].first), all[i].second = i; sort(all, all + n); for (int i = 1; i < n; ++i) if (all[i].first <= all[i - 1].first) all[i].first = all[i - 1].first + 1; sort(all, all + n, cmp); for (int i = 0; i < n - 1; ++i) printf("%d ", all[i].first); printf("%d\n", all[n - 1].first); } }
#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::sync_with_stdio(0); cin.tie(0); auto start = chrono::high_resolution_clock::now(); long long n, m = 1e18, c = 0, d = 0, q = 0, curx = 0, cury = 0, mx = 1e18, h = 0, l = 0, mn = 1e9 + 7, v = 1e17, w = -100000, u = 0, r = 0, k = 0, j = 0, i = 0, ans = 0; cin >> n; vector<pair<long long, long long>> a(n); for (int i = 0; i < n; i++) { cin >> d; a[i].first = d, a[i].second = i; } sort(a.begin(), a.end()); for (int i = 0; i < n; i++) { a[i].first = max(h, a[i].first); h = a[i].first + 1; } sort(a.begin(), a.end(), sortbysec); for (int i = 0; i < n; i++) { cout << a[i].first << " "; } cout << endl; }
#include <bits/stdc++.h> using namespace std; struct data { long long val, ind; data() {} data(long long V, long long I) { val = V; ind = I; } }; long long n, m, len, a, b, ans; string str; data arr[300099]; bool com(data x, data y) { return x.val < y.val; } map<long long, int> M; int mv; long long boro, fina[300099]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> a; arr[i] = data(a, i); } sort(arr, arr + n, com); for (int i = 0; i < n; i++) { long long value = arr[i].val; long long index = arr[i].ind; if (M[value] == 0) { fina[index] = value; M[value] = ++mv; boro = max(boro, value); } else { fina[index] = boro + 1; M[boro + 1] = ++mv; boro++; } } for (int i = 0; i < n; i++) cout << fina[i] << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> g[300100]; int r[300100]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &g[i].first), g[i].second = i; sort(g, g + n); int lst = 0; for (int i = 0; i < n; i++) { if (g[i].first <= lst) r[g[i].second] = ++lst; else r[g[i].second] = lst = g[i].first; } for (int i = 0; i < n; i++) { if (i) printf(" "); printf("%d", r[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, i, j, k, l, t, d, x, y; cin >> n; vector<pair<long long int, long long int>> v; for (i = 0; i < n; i++) { cin >> x; v.push_back({x, i}); } sort(v.begin(), v.end()); x = 1; long long int a[n + 5]; for (i = 0; i < n; i++) { if (v[i].first >= x) { a[v[i].second] = v[i].first; x = v[i].first + 1; } else { a[v[i].second] = x; x++; } } for (i = 0; i < n; i++) cout << a[i] << " "; cout << endl; }
#include <bits/stdc++.h> using namespace std; int di[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dj[] = {1, -1, 0, 0, 1, -1, 1, -1}; int ans[300005]; int main() { ios_base::sync_with_stdio(false); int n, a; cin >> n; vector<pair<int, int> > vec; for (int i = 0; i < n; i++) { cin >> a; vec.push_back(make_pair(a, i)); } sort(vec.begin(), vec.end()); int mx = 0; for (int i = 0; i < ((int)vec.size()); i++) ans[vec[i].second] = mx = max(mx + 1, vec[i].first); for (int i = 0; i < n; i++) cout << ans[i] << " \n"[i == n - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; struct ar { int val; int in; int c; } a[6000 * 101]; bool f(ar x, ar y) { return x.val < y.val; } bool f1(ar x, ar y) { return x.in < y.in; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].val; a[i].in = i; } sort(a, a + n, f); int s = a[0].val; a[0].c = s; for (int i = 1; i < n; i++) { s = max(a[i].val, s + 1); a[i].c = s; } sort(a, a + n, f1); for (int i = 0; i < n; i++) cout << a[i].c << " "; return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int val, id; bool operator<(const node &s) const { return val < s.val; } } qe[300001]; int a[300001]; int main() { int i, n, m, j; int MAX, aa, b; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; i++) { scanf("%d", &qe[i].val); qe[i].id = i; } sort(qe, qe + n); MAX = a[qe[0].id] = qe[0].val; MAX++; for (i = 1; i < n; i++) { if (qe[i].val < MAX) a[qe[i].id] = MAX; else a[qe[i].id] = qe[i].val; MAX = a[qe[i].id] + 1; } cout << a[0]; for (i = 1; i < n; i++) cout << " " << a[i]; puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; struct paire { int pos; int val; }; bool sortbyval(const paire &a, const paire &b) { return (a.val < b.val); } bool sortbypos(const paire &a, const paire &b) { return (a.pos < b.pos); } int main() { int n; cin >> n; paire a[n]; for (int i = 0; i < n; i++) { cin >> a[i].val; a[i].pos = i; } sort(a, a + n, sortbyval); int max = -1; for (int i = 0; i < n; i++) if (a[i].val > max) max = a[i].val; else { a[i].val = max + 1; max += 1; } sort(a, a + n, sortbypos); for (int i = 0; i < n; i++) cout << a[i].val << " "; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 300 * 1000; pair<int, int> sarr[MAXN + 10]; int arr[MAXN + 10]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; sarr[i].first = arr[i]; sarr[i].second = i; } sort(sarr, sarr + n); arr[sarr[0].second] = sarr[0].first; for (int i = 1; i < n; i++) { if (sarr[i].first <= sarr[i - 1].first) { sarr[i].first += sarr[i - 1].first - sarr[i].first + 1; } arr[sarr[i].second] = sarr[i].first; } for (int i = 0; i < n; i++) { cout << arr[i] << " "; } }
#include <bits/stdc++.h> using namespace std; class po { public: int id, ranks; }; bool cmp1(po p1, po p2) { return p1.id < p2.id; } bool cmp2(po p1, po p2) { return p1.ranks < p2.ranks; } po p[312345]; int main() { int n; while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) scanf("%d", &p[i].ranks), p[i].id = i; sort(p, p + n, cmp2); int mrank = 1; for (int i = 0; i < n; i++) { if (p[i].ranks <= mrank) { p[i].ranks = mrank; mrank++; } else { mrank = p[i].ranks + 1; } } sort(p, p + n, cmp1); for (int i = 0; i < n; i++) printf("%d%c", p[i].ranks, (i == n - 1 ? '\n' : ' ')); } return 0; }
#include <bits/stdc++.h> using namespace std; struct ELE { int v, id; }; int n, p; ELE S[300001]; bool cmp(ELE a, ELE b) { return a.v < b.v; } bool cmp2(ELE a, ELE b) { return a.id < b.id; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &S[i].v), S[i].id = i + 1; sort(S, S + n, cmp); for (int i = 0; i < n; i++) if (i == 0) p = S[i].v; else if (S[i].v <= p) S[i].v = ++p; else S[i].v = p = S[i].v; sort(S, S + n, cmp2); for (int i = 0; i < n; i++) printf("%d ", S[i].v); }
#include <bits/stdc++.h> using namespace std; int n; struct T { int a; int b; } a[400000]; inline bool cmp(T a, T b) { return a.a < b.a; } int an[400000]; int main() { scanf("%d", &n); for (int i = (1); i <= (n); i++) { scanf("%d", &a[i].a); a[i].b = i; } sort(a + 1, a + 1 + n, cmp); int ma = -1; for (int i = (1); i <= (n); i++) { ma++; if (a[i].a > ma) ma = a[i].a; an[a[i].b] = ma; } for (int i = (1); i <= (n); i++) printf("%d ", an[i]); }
#include <bits/stdc++.h> using namespace std; struct node { int a, b; } a[400000]; int n; int ans[400000]; bool cmp(const node &x, const node &y) { return x.a < y.a; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i].a); a[i].b = i; } sort(a + 1, a + n + 1, cmp); int now = 0; for (int i = 1; i <= n; i++) { if (now < a[i].a) now = a[i].a; ans[a[i].b] = now; now++; } for (int i = 1; i <= n - 1; i++) printf("%d ", ans[i]); printf("%d", ans[n]); return 0; }
#include <bits/stdc++.h> using namespace std; int ind[300010]; int arr[300010]; int ret[300010]; bool cmp(int a, int b) { return arr[a] < arr[b]; } int main() { int N; cin >> N; for (int i = 0; i < N; i++) { cin >> arr[i]; ind[i] = i; } sort(ind, ind + N, cmp); ret[ind[0]] = arr[ind[0]]; for (int i = 1; i < N; i++) { int cur = ind[i]; int prev = ind[i - 1]; ret[cur] = max(ret[prev] + 1, arr[cur]); } for (int i = 0; i < N; i++) cout << ret[i] << " "; }
#include <bits/stdc++.h> using namespace std; typedef struct { int i; int x; } KK; KK a[1000000]; int b[1000000]; int cmp(KK x, KK y) { return x.x < y.x; } int main() { int n; while (~scanf("%d", &n)) { for (int i = 0; i < n; i++) { scanf("%d", &a[i].x); a[i].i = i; } sort(a, a + n, cmp); int minn = a[0].x; for (int i = 0; i < n; i++) { if (minn >= a[i].x) { b[a[i].i] = minn++; } else { minn = a[i].x; b[a[i].i] = minn++; } } for (int i = 0; i < n; i++) { if (i == 0) printf("%d", b[i]); else printf(" %d", b[i]); } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > v(n); for (long long i = (0); i < (n); i++) { cin >> v[i].first; v[i].second = i; } sort(v.begin(), v.end()); vector<int> ans(n); int c = 0; for (long long i = (0); i < (n); i++) { c = max(c, v[i].first); ans[v[i].second] = c; c++; } for (int h : ans) { cout << h << " "; } 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()); int m = 0; for (int i = 0; i < n; ++i) { a[i].first = max(a[i].first, m); m = a[i].first + 1; swap(a[i].first, a[i].second); } sort((a).begin(), (a).end()); for (int i = 0; i < n; ++i) cout << a[i].second << ' '; }
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[300000]; bool byscore(pair<int, int> a, pair<int, int> b) { if (a.second < b.second) { return true; } return false; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; arr[i] = make_pair(i, a); } sort(arr, arr + n, byscore); int last = 0; for (int i = 0; i < n; i++) { if (arr[i].second <= last) { arr[i] = make_pair(arr[i].first, last + 1); last = last + 1; } else { last = arr[i].second; } } sort(arr, arr + n); for (int i = 0; i < n; i++) { cout << arr[i].second << " "; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int i, j, k, l, n; pair<int, int> a[300005]; int r[300005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (i = 0; i < n; i++) cin >> a[i].first, a[i].second = i; sort(a, a + n); r[a[0].second] = a[0].first; for (i = 1; i < n; i++) { if (a[i].first <= a[i - 1].first) { a[i].first = a[i - 1].first + 1; r[a[i].second] = a[i].first; } else r[a[i].second] = a[i].first; } for (i = 0; i < n; i++) cout << r[i] << " "; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef struct { int a; int b; } pr; bool operator<(const pr &a, const pr &b) { if (a.a != b.a) return a.a < b.a; else return a.b < b.b; } bool comparison(pr a, pr b) { return a.b < b.b; } pr num[300005]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &num[i].a); num[i].b = i; } sort(num, num + n); int p = 0; for (int i = 1; i < n; i++) { if (num[i].a == num[p].a) { num[i].a = num[i - 1].a + 1; } else p = i; if (num[i].a <= num[i - 1].a) { num[i].a = num[i - 1].a + 1; } } sort(num, num + n, comparison); for (int i = 0; i < n; i++) { if (i == 0) printf("%d", num[i].a); else printf(" %d", num[i].a); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; long long ans[maxn]; map<long long, int> ma; vector<pair<long long, int> > vect; bool sortt(pair<long long, int> p1, pair<long long, int> p2) { return p1.first < p2.first; } int main() { int n; long long temp; cin >> n; for (int i = 0; i < n; i++) { scanf("%lld", &temp); vect.push_back(make_pair(temp, i)); } sort(vect.begin(), vect.end(), sortt); long long latest_; for (int p = 0; p < vect.size(); p++) { if (ma[vect[p].first] == 0) { ans[vect[p].second] = vect[p].first; ma[vect[p].first]++; latest_ = vect[p].first + 1; } else { ans[vect[p].second] = latest_; ma[latest_]++; latest_++; } } for (int i = 0; i < n; i++) { printf("%lld ", ans[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 300100; int n, ans[MAXN]; pair<int, int> arr[MAXN]; int main() { ios ::sync_with_stdio(false); if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); } cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i].first; arr[i].second = i; } sort(arr, arr + n); int cur = 0; for (int i = 0; i < n; i++) { cur = max(cur + 1, arr[i].first); ans[arr[i].second] = cur; } for (int i = 0; i < n; i++) cout << ans[i] << ' '; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; int n; pair<int, int> a[300005], b[300005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); int now = a[0].first + 1; b[0].second = a[0].first; b[0].first = a[0].second; for (int i = 1; i < n; i++) { if (now < a[i].first) now = a[i].first; b[i].second = now; b[i].first = a[i].second; now++; } sort(b, b + n); for (int i = 0; i < n - 1; i++) cout << b[i].second << " "; cout << b[n - 1].second; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<long long, long long> > v(n); for (int i = 0; i < n; ++i) { cin >> v[i].first; v[i].second = i; } sort(v.begin(), v.end()); set<int> s; long long cur_min = 0; for (int i = 0; i < n; ++i) { if (v[i].first > cur_min) cur_min = v[i].first; else { v[i].first = cur_min + 1; ++cur_min; } } 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 << " "; }
#include <bits/stdc++.h> const int MOD = 1000000007; using namespace std; const int N = 1e5 + 5; void solve() { int n; cin >> n; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back({x, i}); } sort(v.begin(), v.end()); set<int> s; vector<int> ans(n); for (auto x : v) { int y = x.first; if (s.find(y) == s.end()) { ans[x.second] = y; s.insert(y); } else { auto it = s.end(); it--; int zz = *it + 1; s.insert(zz); ans[x.second] = zz; } } for (auto x : ans) { cout << x << " "; } cout << endl; } int main() { int t; t = 1; while (t--) { solve(); cout << endl; } }
#include <bits/stdc++.h> using namespace std; const int MAXN = 3 * 1e5 + 7; long long B[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); std::ios::sync_with_stdio(false); int n; cin >> n; pair<pair<long long, long long>, long long> A[n]; for (int i = 0; i < n; i++) { cin >> A[i].first.first; A[i].first.second = i; } sort(A, A + n); A[0].second = A[0].first.first; long long prev = A[0].second; for (int i = 1; i < n; i++) { if (A[i].first.first <= prev) { A[i].second = prev + 1; prev++; } else { A[i].second = A[i].first.first; prev = A[i].second; } } for (int i = 0; i < n; i++) { A[i].first.first = A[i].first.second; } sort(A, A + n); for (int i = 0; i < n; i++) { cout << A[i].second << " "; } 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() { int n; cin >> n; vector<pair<int, int> > v; pair<int, int> p; for (int i = 0; i < n; i++) { int k; cin >> k; p.first = k; p.second = i; v.push_back(p); } 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(), sortbysec); for (int i = 0; i < n; i++) { cout << v[i].first << " "; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); ; 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; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') positive = 0; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return positive ? x : -x; } int N, ans[1000006]; pair<int, int> a[1000006]; int main() { N = read(); for (int i = 1; i <= N; ++i) a[i].first = read(), a[i].second = i; sort(a + 1, a + N + 1); int last = 0; for (int i = 1; i <= N; ++i) { last++; if (a[i].first > last) last = a[i].first; ans[a[i].second] = last; } for (int i = 1; i <= N; ++i) printf("%d%c", ans[i], i < N ? ' ' : '\n'); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[(long long)(5 + 3e5)]; set<int> S, D; int main() { cin >> n; for (int i = 0; i < n; i++) scanf("%d", &a[i]), S.insert(a[i]), D.insert(a[i]); for (int i = 0; i < n; i++) { auto it = S.lower_bound(a[i]); printf("%d ", *it); if (D.count(*it + 1) == 0) S.insert(*it + 1); S.erase(it); } return 0; }
#include <bits/stdc++.h> using namespace std; struct pai { int val; int pos; }; int cmp(const void* a, const void* b) { int aa = (*(struct pai*)a).val; int bb = (*(struct pai*)b).val; return aa - bb; } int cmp2(const void* a, const void* b) { int aa = (*(struct pai*)a).pos; int bb = (*(struct pai*)b).pos; return aa - bb; } int main() { long long int t, i, q; multimap<long long, int> mymap; multimap<long long, int>::iterator it; cin >> t; struct pai a[t + 1]; for (i = 0; i < t; i++) { cin >> q; a[i].val = q; a[i].pos = i; } qsort(a, t, sizeof(struct pai), cmp); q = a[0].val + 1; for (i = 1; i < t; i++) { if (q >= a[i].val) { a[i].val = q; } q = a[i].val + 1; } qsort(a, t, sizeof(struct pai), cmp2); for (i = 0; i < t; i++) cout << a[i].val << " "; return 0; }
#include <bits/stdc++.h> using namespace std; bool f1(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } bool f2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { int tmp; int n; cin >> n; pair<int, int> tmp2; pair<int, int> a[300005]; for (int i = 0; i < n; i++) { cin >> tmp; tmp2.first = tmp; tmp2.second = i; a[i] = tmp2; } stable_sort(a, a + n, f1); tmp2 = a[0]; tmp = tmp2.first; for (int i = 1; i < n; i++) { if (a[i].first > tmp) { tmp2 = a[i]; tmp = tmp2.first; continue; } else { a[i].first = ++tmp; } } sort(a, a + n, f2); for (int i = 0; i < n; i++) { cout << a[i].first << ' '; } cout << endl; }
#include <bits/stdc++.h> std::pair<int, int> v[300000]; int r[300000]; int main() { int i, n; std::cin >> n; for (i = 0; i < n; ++i) { v[i].second = i; std::cin >> v[i].first; } std::sort(v, v + n); int a = 1; for (i = 0; i < n; ++i) { if (a < v[i].first) a = v[i].first; r[v[i].second] = a; ++a; } for (i = 0; i < n; ++i) std::cout << r[i] << ' '; return 0; }
#include <bits/stdc++.h> using namespace std; struct sort_pred { bool operator()(const pair<int, int> &left, const pair<int, int> &right) { return ((left.second < right.second)); } }; int main() { int n, i, x = 0; cin >> n; pair<long long int, int> numbers[n]; for (i = 0; i < n; i++) { cin >> numbers[i].first; numbers[i].second = i; } sort(numbers, numbers + n); for (i = 1; i < n; i++) { if (numbers[i].first <= numbers[i - 1].first) { numbers[i].first += (numbers[i - 1].first - numbers[i].first) + 1; } } sort(numbers, numbers + n, sort_pred()); for (i = 0; i < n; i++) printf("%d ", numbers[i]); cout << endl; return 0; }
#include <bits/stdc++.h> int gcd2(int a, int b) { if (a > b) return gcd2(b, a); if (b % a == 0) return a; return gcd2(b % a, a); } struct s { int v; int in; }; int sortv(const void *v1, const void *v2) { struct s *s1 = (struct s *)v1; struct s *s2 = (struct s *)v2; return s1->v - s2->v; } int sorti(const void *v1, const void *v2) { struct s *s1 = (struct s *)v1; struct s *s2 = (struct s *)v2; return s1->in - s2->in; } struct s o[300000]; using namespace std; int t, w, j, i, m, n, k; int main() { scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &o[i].v); o[i].in = i; } w = sizeof(struct s); qsort(o, n, w, sortv); for (i = 0; i < n - 1; i++) { if (o[i].v == o[i + 1].v) { o[i + 1].v += 1; } if (o[i].v > o[i + 1].v) { o[i + 1].v = o[i].v + 1; } } qsort(o, n, w, sorti); for (i = 0; i < n; i++) { printf("%d ", o[i].v); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 1; int n, cur, ans[N]; pair<int, int> a[N]; int main() { 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++) { cur = max(cur + 1, a[i].first); ans[a[i].second] = cur; } for (int i = 0; i < n; i++) printf("%d ", ans[i]); }
#include <bits/stdc++.h> using namespace std; long long int exp(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } int main() { long long int t, i, j, n; cin >> n; vector<pair<long long int, long long int>> v; vector<long long int> b; for (i = 0; i < n; i++) { cin >> j; v.push_back({j, i + 1}); } sort(v.begin(), v.end()); long long int count = v[0].first; b.push_back(count); for (i = 1; i < n; i++) { if (v[i].first == v[i - 1].first) { b.push_back(++count); } else { if (v[i].first > count) { b.push_back(v[i].first); count = v[i].first; } else { b.push_back(++count); } } } for (i = 0; i < n; i++) { v[i].first = b[i]; swap(v[i].first, v[i].second); } sort(v.begin(), v.end()); for (i = 0; i < n; i++) cout << v[i].second << " "; cout << endl; }
#include <bits/stdc++.h> using namespace std; pair<int, int> d[400000]; int ans[400000]; int main() { int n; while (scanf("%d", &n) == 1) { for (int(i) = 0; (i) < (n); (i)++) { scanf("%d", &d[i].first); d[i].second = i; } sort(d, d + n); int m = 0; for (int(i) = 0; (i) < (n); (i)++) { if (d[i].first <= m) { d[i].first = m + 1; } m = d[i].first; ans[d[i].second] = m; } 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; long long a[400005], id[400005]; bool cmp(long long x, long long y) { return a[x] < a[y]; } int main() { long long n, i, x; cin >> n; for (i = 0; i < n; i++) { id[i] = i; cin >> a[i]; } sort(id, id + n, cmp); long long last = -1; for (i = 0; i < n; i++) { x = id[i]; if (last < a[x]) { last = a[x]; a[x] = a[x]; } else { a[x] = last + 1; last++; } } for (i = 0; i < n; i++) { if (i != n - 1) cout << a[i] << " "; else cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<pair<long long, long long> > v(n); for (int i = 0; i < n; i++) { cin >> v[i].first; v[i].second = i; } sort(v.begin(), v.end()); vector<long long> ans(n); long long index = 1; map<long long, bool> m; for (int i = 0; i < n; i++) { if (m.find(v[i].first) == m.end()) { m[v[i].first] = true; if (v[i].first > index) index = v[i].first; ans[v[i].second] = index; index++; } else { if (v[i].first > index) index = v[i].first; ans[v[i].second] = index; index++; } } for (int i = 0; i < ans.size(); i++) cout << ans[i] << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int size, i, current, input[310000], arr[310000], output[310000]; bool comparison(int a, int b) { return input[a] < input[b]; } int main() { cin >> size; for (i = 1; i <= size; i++) { cin >> input[i]; arr[i] = i; } sort(arr + 1, arr + size + 1, comparison); for (i = 1; i <= size; i++) { current = max(current + 1, input[arr[i]]); output[arr[i]] = current; } for (i = 1; i <= size; i++) { cout << output[i] << ' '; } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; struct cmp { bool operator()(const pair<int, unsigned long long int> &a, const pair<int, unsigned long long int> &b) { return (a.second > b.second); } }; int n, i, j; unsigned long long int r; priority_queue<pair<int, unsigned long long int>, vector<pair<int, unsigned long long int> >, cmp> usuarios; unsigned long long int regalos[300001]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> r; usuarios.push(make_pair(i, r)); } pair<int, unsigned long long int> act; unsigned long long int ract = 1, rreal = 1; ; while (!usuarios.empty()) { act = usuarios.top(); usuarios.pop(); if (act.second == rreal) { regalos[act.first] = ract; ract++; } else { if (act.second >= ract) { regalos[act.first] = act.second; rreal = act.second; ract = rreal + 1; } else { regalos[act.first] = ract; rreal = ract; ract++; } } } cout << regalos[0]; for (i = 1; i < n; i++) { cout << " " << regalos[i]; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct st { int num; int id; } a[300009]; int N; inline bool cmp(st a, st b) { return a.num < b.num; } inline bool idc(st a, st b) { return a.id < b.id; } void Read() { scanf("%d", &N); for (int i = 1; i <= N; i++) { scanf("%d", &a[i].num); a[i].id = i; } sort(a + 1, a + N + 1, cmp); } void Solve() { for (int i = 2; i <= N; i++) { if (a[i].num <= a[i - 1].num) a[i].num = a[i - 1].num + 1; } sort(a + 1, a + N + 1, idc); for (int i = 1; i <= N; i++) printf("%d ", a[i].num); } int main() { Read(); Solve(); return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; struct node { int x; int id; } a[400000]; int ans[400000]; bool cmp(node a, node b) { return a.x < b.x; } int main() { int n; while (~scanf("%d", &n)) { for (int i = 1; i <= 2; i++) int sss = 1; for (int i = 1; i <= n; i++) { scanf("%d", &a[i].x); a[i].id = i; } sort(a + 1, a + 1 + n, cmp); int s = -1; for (int i = 1; i <= n; i++) { if (a[i].x > s) { ans[a[i].id] = a[i].x; s = a[i].x + 1; } else { ans[a[i].id] = s; s++; } } printf("%d", ans[1]); for (int i = 2; i <= n; i++) { printf(" %d", ans[i]); } } return 0; }
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); unordered_map<int, int> m; int n, i, j, k, l, x; cin >> n; int b[n]; pair<int, int> a[n]; for (i = 0; i < n; i++) { cin >> x; a[i] = make_pair(x, i); } sort(a, a + n); b[a[0].second] = a[0].first; m[a[0].first] = 1; for (i = 1; i < n; i++) { if (m[a[i].first] != 0) { a[i].first = a[i - 1].first + 1; m[a[i].first] = 1; b[a[i].second] = a[i].first; } else { b[a[i].second] = a[i].first; m[a[i].first] = 1; } } for (i = 0; i < n; i++) cout << b[i] << " "; }
#include <bits/stdc++.h> using namespace std; int a[300000], i, j, n; int main() { cin >> n; vector<pair<int, int> > v(n); for (i = 0; i < n; ++i) { cin >> v[i].first; v[i].second = i; } sort(v.begin(), v.end()); j = 0; for (i = 0; i < n; ++i) { j++; if (j < v[i].first) j = v[i].first; a[v[i].second] = j; } for (i = 0; i < n; ++i) cout << a[i] << " "; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, curr; cin >> n; long long ans[n]; vector<pair<long long, long long> > v(n); for (long long i = 0; i < n; i++) { cin >> v[i].first; v[i].second = i; } sort(v.begin(), v.end()); curr = v[0].first; for (long long i = 0; i < n; i++) { v[i].first = max(v[i].first, curr); curr = v[i].first + 1; } for (long long i = 0; i < n; i++) ans[v[i].second] = v[i].first; for (long long i = 0; i < n; i++) cout << ans[i] << " "; return 0; }