Submission #1004203

# Submission time Handle Problem Language Result Execution time Memory
1004203 2024-06-21T06:25:46 Z 0pt1mus23 Horses (IOI15_horses) C++14
0 / 100
21 ms 26204 KB
/*
	understand error submission
*/
#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];

int func(){
	int ans=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( (long long)dp[i+1][y-k], (dp[i][j] + (k)*1LL * brr[i] + mod) %mod));
				}
			}

		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=dse;j++){
			ans=max(ans,( dp[i][j] + mod )%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();
}

Compilation message

horses.cpp: In function 'int func()':
horses.cpp:38:27: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   38 |      dp[i+1][ y-k ] = (max( (long long)dp[i+1][y-k], (dp[i][j] + (k)*1LL * brr[i] + mod) %mod));
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 26204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -