Submission #411464

#TimeUsernameProblemLanguageResultExecution timeMemory
411464losmi247Horses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e3+23; const int mod = 1000000007; int n; ll x[N],y[N]; ll dp[N][1005]; ll init(int n1,int *x1,int *y1){ n = n1; for(int i = 1; i <= n; i++) x[i] = x1[i-1], y[i] = y1[i-1]; for(int i = 0; i <= n; i++){ for(int j = 0; j <= 1000; j++){ dp[i][j] = -1; } } dp[0][1] = 0; for(int i = 1; i <= n; i++){ /// nakon kraja i-te godine for(ll j = 0; j <= 1000; j++){ /// imam j konja posle prodavanja int nagore = (j+x[i]-1)/x[i]; nagore *= x[i]; for(ll pre = nagore; pre <= 1000; pre += x[i]){ /// koliko sam konja imao pre prodavanja if(dp[i-1][pre/x[i]] != -1) dp[i][j] = max(dp[i][j],dp[i-1][pre/x[i]]+(pre-j)*y[i]); } } } return dp[n][0]; } ll updateX(int pos,int val){ return 0; } ll updateY(int pos,int val){ return 0; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int a; cin >> a; int *prvi = (int*)malloc(sizeof(int)*a); int *drugi = (int*)malloc(sizeof(int)*a); for(int i = 1; i <= a; i++){ int x; cin >> x; prvi[i-1] = x; } for(int i = 1; i <= a; i++){ int x; cin >> x; drugi[i-1] = x; } cout << init(a,prvi,drugi) << endl; }

Compilation message (stderr)

horses.cpp: In function 'll init(int, int*, int*)':
horses.cpp:23:36: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   23 |             int nagore = (j+x[i]-1)/x[i];
      |                          ~~~~~~~~~~^~~~~
horses.cpp:24:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   24 |             nagore *= x[i];
      |             ~~~~~~~^~~~~~~
horses.cpp: In function 'll updateX(int, int)':
horses.cpp:34:16: warning: unused parameter 'pos' [-Wunused-parameter]
   34 | ll updateX(int pos,int val){
      |            ~~~~^~~
horses.cpp:34:24: warning: unused parameter 'val' [-Wunused-parameter]
   34 | ll updateX(int pos,int val){
      |                    ~~~~^~~
horses.cpp: In function 'll updateY(int, int)':
horses.cpp:38:16: warning: unused parameter 'pos' [-Wunused-parameter]
   38 | ll updateY(int pos,int val){
      |            ~~~~^~~
horses.cpp:38:24: warning: unused parameter 'val' [-Wunused-parameter]
   38 | ll updateY(int pos,int val){
      |                    ~~~~^~~
horses.cpp: In function 'int main()':
horses.cpp:51:13: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   51 |         int x;
      |             ^
horses.cpp:8:4: note: shadowed declaration is here
    8 | ll x[N],y[N];
      |    ^
horses.cpp:56:13: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   56 |         int x;
      |             ^
horses.cpp:8:4: note: shadowed declaration is here
    8 | ll x[N],y[N];
      |    ^
/usr/bin/ld: /tmp/ccwbqqN2.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccaepAuZ.o:horses.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status