답안 #1004408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004408 2024-06-21T08:41:09 Z vjudge1 말 (IOI15_horses) C++17
0 / 100
243 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
#define vi vector<int>

int n ;
vi x, y;


ll init(int N, int X[], int Y[]){
    n = N;
    x.resize(N);
    y.resize(N);
    for(int i =0; i < n; i++){
        x[i] =X[i];
        y[i] = Y[i];
    }
    
    ll final = 0;
    ll dp[n+10][10002];
    for(int i = 0; i <= n; i++){
        for(int j= 0; j < 10001;j++){
            dp[i][j]=-LLONG_MAX;
        }
    }
    dp[0][1]=0;
   for(int i = 1; i <= n; i++){
       //dp[0][i] =dp[0][i-1]; 
       for(int j = 0; j < 1000; j++){
           for(int k = 0; k <= (j+(j*x[i-1])); k++){
               ll have = j*x[i-1];
              if(have>10000)break;
           //   cout << i << " "<<j << " " << dp[i-1][j]<<endl;
              if(dp[i-1][j] >=0) dp[i][have-k] = max(dp[i][have-k] ,dp[i-1][j] +  (y[i-1] * k));
           }
       }
   }

   ll ans = 0;
  // cout << dp[n][0]<<endl;
   for(int i = 0; i <n; i++){
       ans = max(ans,dp[i][0]);
   }
    for(int i = 0; i < 10001; i++){
     //  cout <<i<<" "<< dp[n][i]<<endl;
        ans= max(ans,dp[n][i]);
    }
    return ans;
}


void updateX(int pos, int val){
    x[pos]=val;
}

void updateY(int pos, int val){
    y[pos]=val;
}

Compilation message

horses.cpp: In function 'long long int init(int, int*, int*)':
horses.cpp:24:8: warning: unused variable 'final' [-Wunused-variable]
   24 |     ll final = 0;
      |        ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 14 ms 1884 KB Output is correct
3 Incorrect 19 ms 1884 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 15 ms 2000 KB Output is correct
3 Incorrect 19 ms 1992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 243 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 14 ms 1996 KB Output is correct
3 Incorrect 19 ms 1884 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 15 ms 1884 KB Output is correct
3 Incorrect 19 ms 1884 KB Output isn't correct
4 Halted 0 ms 0 KB -