Submission #852684

#TimeUsernameProblemLanguageResultExecution timeMemory
852684tvgkHoliday (IOI14_holiday)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define task "" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 1e5 + 7; ii tree[mxN * 4], a[mxN]; ll num, mx, tmp, ans, vt[mxN], j; void Up(int j) { tree[j].se = tree[j * 2].se + tree[j * 2 + 1].se; tree[j].fi = 0; if (tree[j * 2].se) tree[j].fi += tree[j * 2].fi; if (tree[j * 2 + 1].se) tree[j].fi += tree[j * 2 + 1].fi; } void Build(int j, int l, int r) { if (l == r) { tree[j].fi = a[l].fi; return; } int mid = (l + r) / 2; Build(j * 2, l, mid); Build(j * 2 + 1, mid + 1, r); } ll Get(int j, int l, int r) { if (tree[j].se <= num) { num -= tree[j].se; return tree[j].fi; } if ((!tree[j].se) || (num <= 0)) return 0; int mid = (l + r) / 2; return Get(j * 2 + 1, mid + 1, r) + Get(j * 2, l, mid); } void Update(int j, int l, int r, int vt, int tt) { if (l > vt || vt > r) return; if (l == r) { tree[j].se = tt; return; } int mid = (l + r) / 2; Update(j * 2, l, mid, vt, tt); Update(j * 2 + 1, mid + 1, r, vt, tt); Up(j); } long long int findMaxAttraction(ll n, ll stt, ll day, ll att[]) { stt++; for (int i = 1; i <= n; i++) { a[i].fi = att[i - 1]; a[i].se = i; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) vt[a[i].se] = i; Build(1, 1, n); for (int i = stt; i <= n; i++) Update(1, 1, n, vt[i], 1); j = n; for (int i = stt; i >= 1; i--) { Update(1, 1, n, vt[i], 1); num = day - (j - i) - min(stt - i, j - stt); mx = Get(1, 1, n); while (j > stt) { Update(1, 1, n, vt[j], 0); j--; num = day - (j - i) - min(stt - i, j - stt); tmp = Get(1, 1, n); if (tmp >= mx) mx = tmp; else { j++; Update(1, 1, n, vt[j], 1); break; } } ans = max(ans, mx); } return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccPOCNXK.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status