Submission #1069590

# Submission time Handle Problem Language Result Execution time Memory
1069590 2024-08-22T06:26:45 Z UmairAhmadMirza Closing Time (IOI23_closing) C++17
9 / 100
40 ms 14944 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=3005;

ll Xd[N],Yd[N],Mxd[N],Mnd[N],sim[N];
vector<ll> dst,st;

int max_score(int n, int X, int Y, long long K, vector<int> U,
              vector<int> V, vector<int> W)
{
	vector<int> wei(n+1,0);
	for(int i=0;i<n;i++)
		wei[i+1]=W[i];
	X++;
	Y++;
	for(int i=X+1;i<=n;i++)
		Xd[i]=Xd[i-1]+wei[i-1];
	for(int i=X-1;i>=1;i--)
		Xd[i]=Xd[i+1]+wei[i];
	for(int i=Y+1;i<=n;i++)
		Yd[i]=Yd[i-1]+wei[i-1];
	for(int i=Y-1;i>=1;i--)
		Yd[i]=Yd[i+1]+wei[i];
	for (int i = 1; i <=n; ++i){
		Mxd[i]=max(Xd[i],Yd[i]);
		Mnd[i]=min(Xd[i],Yd[i]);
		sim[i]=sim[i-1]+Mnd[i];
	}
	ll t=Xd[Y];
	for (int i = X; i <=Y; ++i)
		dst.push_back(Mxd[i]-Mnd[i]);
	sort(dst.begin(), dst.end());
	for (int i = 1; i < dst.size(); ++i)
		dst[i]+=dst[i-1];
	for (int i = 1; i <=n; ++i)
		st.push_back(Mnd[i]);
	sort(st.begin(), st.end());
	for (int i = 1; i < n; ++i)
		st[i]+=st[i-1];
	int ans=upper_bound(st.begin(), st.end(),K)-st.begin();
	for(int l=1;l<=X;l++)
		for(int r=Y;r<=n;r++){
			ll ot=(X-l)+(r-Y);
			ll cost=K-(sim[r]-sim[l-1]);
			if(cost<0)
				continue;
			int cnt=(r-l)+1;
			int ind=upper_bound(dst.begin(), dst.end(),cost)-dst.begin();
			cnt+=ind;
			if(ind==dst.size()){
				cost-=dst.back();
				cnt+=min(ot,cost/t);
			}
			ans=max(ans,cnt);
		}
	return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 1; i < dst.size(); ++i)
      |                  ~~^~~~~~~~~~~~
closing.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    if(ind==dst.size()){
      |       ~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 14944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 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 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '25', found: '40'
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '25', found: '40'
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -