Submission #596988

#TimeUsernameProblemLanguageResultExecution timeMemory
596988PiejanVDCHorses (IOI15_horses)C++17
17 / 100
1562 ms10464 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; vector<int>x,y; int init(int n, int X[], int Y[]) { for(int i = 0 ; i < n ; i++) x.push_back(X[i]), y.push_back(Y[i]); int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; if(y[i] * (got-1) > prev) last = i, prev = y[i] * (got-1); // + case where you sell all of them ans = max(ans, curr + y[i] * got); } curr += prev; prev = -1; got = 1; } ans = max(ans, curr); return ans; } int updateX(int p, int val) { int n = (int)x.size(); x[p] = val; int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; if(y[i] * (got-1) > prev) last = i, prev = y[i] * (got-1); // + case where you sell all of them ans = max(ans, curr + y[i] * got); } curr += prev; prev = -1; got = 1; } ans = max(ans, curr); return ans; } int updateY(int p, int val) { int n = (int)x.size(); y[p] = val; int last = -1; long long got = 1; long long ans = 0; long long curr = 0; long long prev = -1; while(last < n-1) { for(int i = last+1 ; i < n ; i++) { got *= x[i]; if(y[i] * (got-1) > prev) last = i, prev = y[i] * (got-1); // + case where you sell all of them ans = max(ans, curr + y[i] * got); } curr += prev; prev = -1; got = 1; } ans = max(ans, curr); return ans; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:31:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   31 |     return ans;
      |            ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:59:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   59 |     return ans;
      |            ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:87:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   87 |     return ans;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...