답안 #887632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887632 2023-12-14T21:40:31 Z amirhoseinfar1385 Xylophone (JOI18_xylophone) C++17
100 / 100
58 ms 1272 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+10;
int dp2[maxn],dp3[maxn],n,val[maxn],vas[maxn],all[maxn];
void solve(int N) {
	n=N;
	//cout<<"wtf"<<n<<endl;
	for(int i=2;i<=n;i++){
		dp2[i]=query(i-1,i);
	}
	for(int i=3;i<=n;i++){
		dp3[i]=query(i-2,i);
	}
	val[2]=dp2[2];
	vas[2]=1;
	for(int i=3;i<=n;i++){
		if(dp3[i]==dp2[i-1]){
			vas[i]=-vas[i-1];
			val[i]=dp2[i];
			continue;
		}
		if(dp3[i]==dp2[i]){
			vas[i]=-vas[i-1];
			val[i]=dp2[i];
			continue;
		}
		vas[i]=vas[i-1];
		val[i]=dp2[i];
	}
	pair<int,int>mina,maxa;
	mina=make_pair(0,1);
	maxa=make_pair(0,1);
	for(int i=2;i<=n;i++){
		all[i]=all[i-1]+val[i]*vas[i];
		mina=min(mina,make_pair(all[i],i));
		maxa=max(maxa,make_pair(all[i],i));
	}
	if(mina.second>maxa.second){
		for(int i=2;i<=n;i++){
			vas[i]=-vas[i];
			all[i]=all[i-1]+val[i]*vas[i];
		}
	}
	int tof=0;
	for(int i=2;i<=n;i++){
		tof=min(tof,all[i]);
	}
	for(int i=1;i<=n;i++){
		all[i]+=-tof+1;
		//cout<<i<<" "<<all[i]<<" "<<tof<<endl;
		answer(i,all[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 0 ms 612 KB Output is correct
3 Correct 0 ms 612 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 700 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 700 KB Output is correct
14 Correct 1 ms 680 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 0 ms 612 KB Output is correct
3 Correct 0 ms 612 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 700 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 700 KB Output is correct
14 Correct 1 ms 680 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
16 Correct 2 ms 708 KB Output is correct
17 Correct 4 ms 452 KB Output is correct
18 Correct 8 ms 456 KB Output is correct
19 Correct 9 ms 700 KB Output is correct
20 Correct 11 ms 456 KB Output is correct
21 Correct 8 ms 700 KB Output is correct
22 Correct 9 ms 856 KB Output is correct
23 Correct 9 ms 700 KB Output is correct
24 Correct 7 ms 696 KB Output is correct
25 Correct 7 ms 452 KB Output is correct
26 Correct 9 ms 456 KB Output is correct
27 Correct 9 ms 452 KB Output is correct
28 Correct 11 ms 444 KB Output is correct
29 Correct 12 ms 444 KB Output is correct
30 Correct 8 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 0 ms 612 KB Output is correct
3 Correct 0 ms 612 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 1 ms 708 KB Output is correct
7 Correct 1 ms 452 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 700 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 700 KB Output is correct
14 Correct 1 ms 680 KB Output is correct
15 Correct 1 ms 448 KB Output is correct
16 Correct 2 ms 708 KB Output is correct
17 Correct 4 ms 452 KB Output is correct
18 Correct 8 ms 456 KB Output is correct
19 Correct 9 ms 700 KB Output is correct
20 Correct 11 ms 456 KB Output is correct
21 Correct 8 ms 700 KB Output is correct
22 Correct 9 ms 856 KB Output is correct
23 Correct 9 ms 700 KB Output is correct
24 Correct 7 ms 696 KB Output is correct
25 Correct 7 ms 452 KB Output is correct
26 Correct 9 ms 456 KB Output is correct
27 Correct 9 ms 452 KB Output is correct
28 Correct 11 ms 444 KB Output is correct
29 Correct 12 ms 444 KB Output is correct
30 Correct 8 ms 448 KB Output is correct
31 Correct 19 ms 708 KB Output is correct
32 Correct 28 ms 700 KB Output is correct
33 Correct 44 ms 956 KB Output is correct
34 Correct 56 ms 768 KB Output is correct
35 Correct 58 ms 1208 KB Output is correct
36 Correct 50 ms 704 KB Output is correct
37 Correct 44 ms 1008 KB Output is correct
38 Correct 51 ms 968 KB Output is correct
39 Correct 49 ms 1272 KB Output is correct
40 Correct 49 ms 708 KB Output is correct
41 Correct 52 ms 692 KB Output is correct
42 Correct 43 ms 712 KB Output is correct
43 Correct 45 ms 460 KB Output is correct
44 Correct 36 ms 708 KB Output is correct
45 Correct 47 ms 960 KB Output is correct
46 Correct 42 ms 764 KB Output is correct
47 Correct 41 ms 956 KB Output is correct
48 Correct 57 ms 960 KB Output is correct
49 Correct 45 ms 956 KB Output is correct
50 Correct 45 ms 1012 KB Output is correct
51 Correct 47 ms 700 KB Output is correct
52 Correct 56 ms 960 KB Output is correct
53 Correct 45 ms 948 KB Output is correct
54 Correct 56 ms 956 KB Output is correct
55 Correct 42 ms 712 KB Output is correct
56 Correct 38 ms 692 KB Output is correct
57 Correct 42 ms 1212 KB Output is correct
58 Correct 57 ms 960 KB Output is correct
59 Correct 58 ms 948 KB Output is correct
60 Correct 50 ms 1012 KB Output is correct