Submission #1004255

# Submission time Handle Problem Language Result Execution time Memory
1004255 2024-06-21T06:50:51 Z 0pt1mus23 Horses (IOI15_horses) C++14
17 / 100
1500 ms 13932 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define ins insert
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 5*1e5, prime = 23;
const int inf = INT_MAX;
int arr[sze],brr[sze];
int n;

const int dse = 1e3; 
int dp[dse+1][dse+1];
unordered_map<int,int> dp2[dse+1];
int func(){
	int ans=0;
	if(n<=0){
		for(int i=0;i<=n;i++){
			for(int j=0;j<=dse;j++){
				dp[i][j]=-1;
			}
		}
		dp[0][1]=0;
		for(int i=0;i<n;i++){
			for(int j=1;j<=dse;j++){
				if(dp[i][j]!=-1){
					int y =j * arr[i]; 
					// cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
					for(int k=0;k<=y;k++){
						/*if(k>dse){
							return 17;
						}*/
						dp[i+1][ y-k ] = (max( dp[i+1][y-k], (dp[i][j] + (k)* brr[i] ) %mod));
					}
				}

			}
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<=dse;j++){
				ans=max(ans,( dp[i][j] )%mod);
			}
		}
	}
	else{
		for(int i =0;i<=n;i++){
			dp2[i]=unordered_map<int,int>();
		}
		dp2[0][1]=0;
		for(int i=0;i<n;i++){
			for(auto v:dp2[i]){
				int y =v.first * arr[i]; 
				// cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
				for(int k=0;k<=y;k++){
					/*if(k>dse){
						return 17;
					}*/
					dp2[i+1][ y-k ] = (max( dp2[i+1][y-k], (v.second + (k)* brr[i] ) %mod));
				}

			}
		}
		for(int i=0;i<=n;i++){
			for(auto v:dp2[i]){
				// cout<<i<<" "<<v.second<<endl;
				ans=max(ans,( v.second )%mod);
			}
		}
	}
	return ans;
}

int init(int N, int X[], int Y[]) {
	n=N;
	for(int i=0;i<n;i++){
		arr[i]=X[i];
		brr[i]=Y[i];
	}
	return func();
}

int updateX(int pos, int val) {	
	arr[pos]=val;
	return func();
}

int updateY(int pos, int val) {
	brr[pos]=val;
	return func();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 488 KB Output is correct
3 Correct 26 ms 708 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 428 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 37 ms 708 KB Output is correct
8 Correct 27 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 15 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 420 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 29 ms 676 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 26 ms 756 KB Output is correct
8 Correct 32 ms 792 KB Output is correct
9 Correct 0 ms 348 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 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 15 ms 652 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Execution timed out 1600 ms 5568 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 13932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 608 KB Output is correct
3 Correct 27 ms 604 KB Output is correct
4 Correct 1 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 30 ms 796 KB Output is correct
8 Correct 29 ms 604 KB Output is correct
9 Correct 0 ms 348 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 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 13 ms 648 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 4 ms 604 KB Output is correct
21 Execution timed out 1528 ms 5476 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 29 ms 680 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 28 ms 728 KB Output is correct
8 Correct 28 ms 600 KB Output is correct
9 Correct 0 ms 348 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 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 11 ms 648 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Execution timed out 1522 ms 5472 KB Time limit exceeded
22 Halted 0 ms 0 KB -