CSES - Harjoituskisa 7.1.2018 - Results
Submission details
Task:Keskiarvot
Sender:ArktinenKarpalo
Submission time:2018-01-07 21:14:18 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.05 s1details
#30.05 s1details
#40.04 s1details
#50.04 s1details
#60.05 s2details
#70.05 s2details
#80.05 s2details
#90.04 s2details
#100.05 s2details
#110.10 s3details
#120.12 s3details
#130.12 s3details
#140.14 s3details
#150.16 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:50:32: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(it!=s.begin()||it==s.end()&&s.size()>0) {
                                ^

Code

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define N 202020

using namespace std;

ll sp[N*2];
int n, vasen, oikee, summa, ans[101010];
vector<int> a;
set<pair<int,int>> s;

ll sum(int aa, int bb) {
	aa+=N;
	bb+=N;
	ll ret = 0;
	while(aa<=bb) {
		if(aa%2==1)
			ret += sp[aa++];
		if(bb%2==0)
			ret+= sp[bb--];
		aa/=2;
		bb/=2;
	}
	return ret;
}

void chg(int k, int x) {
	k+=N;
	sp[k] = x;
	k/=2;
	while(k>=1) {
		sp[k] = sp[2*k+1] + sp[2*k];
		k/=2;
	}
}

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n;
	a.resize(n);
	for(int i=1; i<=n; i++) {
		cin >> a[i];
		chg(i, a[i]);
		oikee++;
		auto it = s.lower_bound(make_pair(a[i], 0));

		if(it!=s.begin()||it==s.end()&&s.size()>0) {
			it--;
			ans[i] = i-(*it).second;
			s.insert(make_pair(sum((*it).second, i)/ans[i], i));
		} else {
			ans[i] = 1;
			s.insert(make_pair(a[i], i));
		}

	}
	for(int i=1; i<=n; i++)
		cout << ans[i] << " ";
}

Test details

Test 1

Group: 1

Verdict:

input
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 2

Group: 1

Verdict:

input
100
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 2 1 2 3 1 4 1 2 3 4 1 4 5 ...

Test 3

Group: 1

Verdict:

input
100
1000000 999999 999998 999997 9...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 4

Group: 1

Verdict:

input
100
4 1 6 9 4 793899 5 5 8 7 5 4 7...

correct output
1 2 1 1 2 1 2 3 4 5 6 7 8 9 10...

user output
1 1 2 1 3 2 6 7 4 5 10 10 9 11...

Test 5

Group: 1

Verdict:

input
100
442147 824215 62008 513740 542...

correct output
1 1 2 1 1 3 1 2 6 10 11 12 1 1...

user output
1 1 1 3 4 3 3 5 6 1 8 9 5 7 2 ...

Test 6

Group: 2

Verdict:

input
5000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 7

Group: 2

Verdict:

input
5000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 2 1 2 3 1 4 1 2 3 4 1 4 5 ...

Test 8

Group: 2

Verdict:

input
5000
1000000 999999 999998 999997 9...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 9

Group: 2

Verdict:

input
5000
7 5 6 1 9 1 1 6 10 8 7 4 7 1 1...

correct output
1 2 3 4 1 2 7 1 1 2 3 4 5 6 1 ...

user output
1 1 1 1 4 1 1 6 4 5 2 5 4 1 2 ...

Test 10

Group: 2

Verdict:

input
5000
236071 202283 94200 149202 642...

correct output
1 2 3 4 1 1 2 3 5 1 2 1 9 10 1...

user output
1 1 1 1 1 1 3 4 6 3 7 3 9 1 13...

Test 11

Group: 3

Verdict:

input
100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 12

Group: 3

Verdict:

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 2 1 2 3 1 4 1 2 3 4 1 4 5 ...

Test 13

Group: 3

Verdict:

input
100000
1000000 999999 999998 999997 9...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 14

Group: 3

Verdict:

input
100000
4 10 3 2 235575 7 374394 4 4 5...

correct output
1 1 2 3 1 2 1 2 3 6 7 8 9 10 1...

user output
1 1 1 1 3 5 2 5 6 9 10 9 1 1 1...

Test 15

Group: 3

Verdict:

input
100000
243549 902542 256118 941342 41...

correct output
1 1 2 1 2 5 6 1 8 9 1 2 12 13 ...

user output
1 1 2 1 4 1 6 5 3 9 8 6 1 13 9...