Submission #61579609
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*
~~ Alguma parte/frase foda de um livro/mangá para dar sorte ~~
Uma vez eu gritei, gradualmente, perdi minha voz.
Uma vez eu chorei, gradualmente, perdi minhas lágrimas.
Uma vez eu sofri, gradualmente, me tornei capaz de suportar tudo.
Uma vez me alegrei, gradualmente, me tornei indiferente ao mundo.
E agora, tudo o que me resta é um rosto sem expressão,
meu olhar é tão firme quanto um monólito,
apenas a perseverança permanece no meu coração.
Este sou eu, um personagem insignificante,
Fang Yuan — A Perseverança.
*/
#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0)
#define pb push_back
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define Unique(v) \
sort(all(v)); \
v.erase(unique(all(v)), v.end()); \
v.shrink_to_fit()
#define sz(v) ((int)v.size())
#define sor(x) sort(all(x))
#define ft front()
#define bk back()
#define endl "\n"
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef tuple<int, int, int> tiii;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int mod = 1e9 + 7;
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
cerr << ' ' << H;
dbg_out(T...);
}
#define dbg(...) cerr << "(" << _VA_ARGS_ << "):", dbg_out(_VA_ARGS_), cerr << endl
struct Fenwick {
int n;
vector<int> fenw;
Fenwick(int n) : n(n), fenw(n+1, 0) {}
void update(int i, int val) {
for (; i <= n; i += i & -i) {
fenw[i] += val;
}
}
int query(int i) {
int s = 0;
for (; i > 0; i -= i & -i) {
s += fenw[i];
}
return s;
}
int rangeQuery(int l, int r) {
if (l > r) return 0;
return query(r) - query(l-1);
}
};
void solve()
{
int n; cin >> n;
vi a(n+1);
rep(i, 1, n+1) cin >> a[i];
vi diff(n+2, 0LL), ans(n+1, 0LL);
int prefix = 0;
rep(i, 1, n+1) {
prefix += diff[i];
int q = a[i] + prefix;
int d = min(q, n - i);
ans[i] = q - d;
if(d > 0){
if(i + 1 <= n){
diff[i + 1]++;
}
if(i + d + 1 <= n){
diff[i + d + 1]--;
}
}
}
rep(i, 1, n+1) cout << ans[i] << " ";
cout << endl;
}
int32_t main()
{
IOS;
int tt;
tt = 1;
while (tt--)
solve();
return 0;
}
Submission Info
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample00.txt, sample01.txt, sample02.txt |
All |
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt |
Case Name |
Status |
Exec Time |
Memory |
sample00.txt |
AC |
1 ms |
3468 KB |
sample01.txt |
AC |
1 ms |
3420 KB |
sample02.txt |
AC |
1 ms |
3608 KB |
testcase00.txt |
AC |
1 ms |
3408 KB |
testcase01.txt |
AC |
38 ms |
14928 KB |
testcase02.txt |
AC |
49 ms |
15600 KB |
testcase03.txt |
AC |
43 ms |
12760 KB |
testcase04.txt |
AC |
51 ms |
15012 KB |
testcase05.txt |
AC |
14 ms |
6208 KB |
testcase06.txt |
AC |
51 ms |
14980 KB |
testcase07.txt |
AC |
41 ms |
12508 KB |
testcase08.txt |
AC |
51 ms |
15004 KB |
testcase09.txt |
AC |
43 ms |
12844 KB |
testcase10.txt |
AC |
50 ms |
14932 KB |
testcase11.txt |
AC |
21 ms |
7796 KB |
testcase12.txt |
AC |
51 ms |
15008 KB |
testcase13.txt |
AC |
33 ms |
10356 KB |
testcase14.txt |
AC |
51 ms |
15004 KB |
testcase15.txt |
AC |
7 ms |
4392 KB |
testcase16.txt |
AC |
53 ms |
14992 KB |
testcase17.txt |
AC |
43 ms |
12812 KB |
testcase18.txt |
AC |
37 ms |
14124 KB |
testcase19.txt |
AC |
34 ms |
13896 KB |