Submission #234247

#TimeUsernameProblemLanguageResultExecution timeMemory
234247jhtanHorses (IOI15_horses)C++14
17 / 100
1592 ms20088 KiB
#include "horses.h" #include <algorithm> using namespace std; typedef long long ll; const ll MOD = 1000000007; ll V[500000]; ll XX[500000]; ll YY[500000]; ll MX[500000]; ll MY[500000]; int n; int init(int N, int X[], int Y[]) { // For 17 points /* int V[N]; V[0] = X[0]; for(int i=1; i<N; i++) V[i] = V[i-1] * X[i]; int mx = 0; for(int i=0; i<N; i++) mx = max(mx, V[i] * Y[i]); */ n = N; for(int i=0; i<N; i++) { YY[i] = Y[i]; XX[i] = X[i]; } MX[0] = X[0] / MOD; V[0] = X[0] % MOD; for(int i=1; i<N; i++) { ll m = V[i-1] * X[i]; MX[i] = (m / MOD) + (MX[i-1] * X[i]); V[i] = m % MOD; } ll mm = 0, mx = 0; for(int i=0; i<N; i++) { ll m1 = MX[i] * Y[i] + ((V[i] * Y[i]) / MOD); ll m2 = (V[i] * Y[i]) % MOD; if(m1 > mm) { mm = m1; mx = m2; } else if (m1 == mm && m2 > mx) { mx = m2; } } return mx; } int updateX(int pos, int val) { XX[pos] = val; for(int i=pos; i<n; i++) { ll m = V[i-1] * XX[i]; MX[i] = (m / MOD) + (MX[i-1] * XX[i]); V[i] = m % MOD; } ll mm = 0, mx = 0; for(int i=0; i<n; i++) { ll m1 = MX[i] * YY[i] + ((V[i] * YY[i]) / MOD); ll m2 = (V[i] * YY[i]) % MOD; if(m1 > mm) { mm = m1; mx = m2; } else if (m1 == mm && m2 > mx) { mx = m2; } } return mx; } int updateY(int pos, int val) { YY[pos] = val; ll mm = 0, mx = 0; for(int i=0; i<n; i++) { ll m1 = MX[i] * YY[i] + ((V[i] * YY[i]) / MOD); ll m2 = (V[i] * YY[i]) % MOD; if(m1 > mm) { mm = m1; mx = m2; } else if (m1 == mm && m2 > mx) { mx = m2; } } return mx; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:55:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return mx;
         ^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:80:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return mx;
         ^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:99:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return mx;
         ^~
#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...