Submission #61559555


Source Code Expand

Copy
#include<bits/stdc++.h>
#define int long long
#define For(i, a, b) for(int i = (a); i <= (b); i++)
#define Rof(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
const int N = 5e5 + 5;
int n, a[N], b[N];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
void Solve(){
cin >> n;
For(i, 1, n) cin >> a[i];
int tag = 0;
For(i, 1, n){
while(!q.empty() && q.top().first <= tag) q.pop();
a[i] += q.size(); //cerr << "a[" << i << "]=" << a[i] << '\n';
tag++; q.push({a[i] + tag, i});
}
while(!q.empty()){
auto [x, y] = q.top(); q.pop();
//cerr << "x=" << x << " y=" << y << '\n';
b[y] = x - tag;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define int long long
#define For(i, a, b) for(int i = (a); i <= (b); i++)
#define Rof(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
const int N = 5e5 + 5;
int n, a[N], b[N];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
void Solve(){
	cin >> n;
	For(i, 1, n) cin >> a[i];
	int tag = 0;
	For(i, 1, n){
		while(!q.empty() && q.top().first <= tag) q.pop();
		a[i] += q.size(); //cerr << "a[" << i << "]=" << a[i] << '\n';
		tag++; q.push({a[i] + tag, i});
	}
	while(!q.empty()){
		auto [x, y] = q.top(); q.pop();
		//cerr << "x=" << x << " y=" << y << '\n';
		b[y] = x - tag;
	}
	For(i, 1, n) cout << b[i] << ' ';
}
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T = 1; //cin >> T;
	while(T--) Solve();
	return 0;
}

Submission Info

Submission Time
Task D - Coming of Age Celebration
User Anyees
Language C++ 20 (gcc 12.2)
Score 400
Code Size 825 Byte
Status AC
Exec Time 123 ms
Memory 19652 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 23
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 3628 KB
sample01.txt AC 1 ms 3480 KB
sample02.txt AC 1 ms 3380 KB
testcase00.txt AC 1 ms 3508 KB
testcase01.txt AC 32 ms 7416 KB
testcase02.txt AC 83 ms 19652 KB
testcase03.txt AC 102 ms 14848 KB
testcase04.txt AC 123 ms 16928 KB
testcase05.txt AC 31 ms 7312 KB
testcase06.txt AC 120 ms 16972 KB
testcase07.txt AC 96 ms 14476 KB
testcase08.txt AC 120 ms 16980 KB
testcase09.txt AC 102 ms 14788 KB
testcase10.txt AC 121 ms 17024 KB
testcase11.txt AC 47 ms 9040 KB
testcase12.txt AC 120 ms 17004 KB
testcase13.txt AC 74 ms 13852 KB
testcase14.txt AC 121 ms 16888 KB
testcase15.txt AC 13 ms 5088 KB
testcase16.txt AC 120 ms 16964 KB
testcase17.txt AC 100 ms 14860 KB
testcase18.txt AC 42 ms 8916 KB
testcase19.txt AC 30 ms 7212 KB


2025-03-05 (Wed)
18:04:33 +00:00