Submission #850612

# Submission time Handle Problem Language Result Execution time Memory
850612 2023-09-17T06:56:13 Z StefanSebez Cat Exercise (JOI23_ho_t4) C++14
41 / 100
175 ms 35260 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
const int N=2*1e5+50;
map<pair<int,int>,int>mapa;
ll dp[N];
int main()
{
    int n;scanf("%i",&n);
    int a[n+1],L[n+1],R[n+1];
    vector<int>mono;
    for(int i=1;i<=n;i++)
	{
		L[i]=0,R[i]=n+1;
		scanf("%i",&a[i]);
		while(!mono.empty() && a[mono.back()]<a[i])
		{
			R[mono.back()]=i;
			mono.pop_back();
		}
		if(!mono.empty()) L[i]=mono.back();
		mono.push_back(i);
	}
	pair<int,int>par[n+1];
	for(int i=1;i<=n;i++)
	{
		mapa[{L[i],R[i]}]=i;
		par[i]=make_pair(R[i]-L[i],i);
	}
	sort(par+1,par+n+1);
	for(int i=1;i<=n;i++)
	{
		int j=par[i].se,maks=0,l=mapa[{L[j],j}],r=mapa[{j,R[j]}];
		if(j-L[j]>1)dp[j]=max(dp[l]+j-l,dp[j]);
		if(R[j]-j>1)dp[j]=max(dp[r]+r-j,dp[j]);
	}
    for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%i%i",&u,&v);
	}
	printf("%lld\n",dp[mapa[{0,n+1}]]);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:19: warning: unused variable 'maks' [-Wunused-variable]
   35 |   int j=par[i].se,maks=0,l=mapa[{L[j],j}],r=mapa[{j,R[j]}];
      |                   ^~~~
Main.cpp:11:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     int n;scanf("%i",&n);
      |           ~~~~~^~~~~~~~~
Main.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%i",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%i%i",&u,&v);
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 1112 KB Output is correct
19 Correct 3 ms 1112 KB Output is correct
20 Correct 4 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 3 ms 1112 KB Output is correct
23 Correct 4 ms 1112 KB Output is correct
24 Correct 3 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 1112 KB Output is correct
19 Correct 3 ms 1112 KB Output is correct
20 Correct 4 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 3 ms 1112 KB Output is correct
23 Correct 4 ms 1112 KB Output is correct
24 Correct 3 ms 1112 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Incorrect 4 ms 1116 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 1112 KB Output is correct
19 Correct 3 ms 1112 KB Output is correct
20 Correct 4 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 3 ms 1112 KB Output is correct
23 Correct 4 ms 1112 KB Output is correct
24 Correct 3 ms 1112 KB Output is correct
25 Correct 148 ms 35016 KB Output is correct
26 Correct 170 ms 34884 KB Output is correct
27 Correct 157 ms 35260 KB Output is correct
28 Correct 170 ms 34632 KB Output is correct
29 Correct 175 ms 34920 KB Output is correct
30 Correct 173 ms 34640 KB Output is correct
31 Correct 175 ms 34512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 756 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 1112 KB Output is correct
19 Correct 3 ms 1112 KB Output is correct
20 Correct 4 ms 1112 KB Output is correct
21 Correct 4 ms 1116 KB Output is correct
22 Correct 3 ms 1112 KB Output is correct
23 Correct 4 ms 1112 KB Output is correct
24 Correct 3 ms 1112 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Incorrect 4 ms 1116 KB Output isn't correct
27 Halted 0 ms 0 KB -