제출 #428273

#제출 시각아이디문제언어결과실행 시간메모리
428273haxorman말 (IOI15_horses)C++14
17 / 100
1587 ms90280 KiB
#include "horses.h" #include "bits/stdc++.h" using namespace std; const int mxN = 5e5 + 7; const int MOD = 1e9 + 7; int n; long long x[mxN], y[mxN]; map<pair<int,long long>,long long> dp; long long rec(int i, long long horses) { horses *= x[i]; if (i == n - 1) { return (y[i] * horses) % MOD; } if (dp.count({i, horses})) { return dp[{i, horses}]; } long long keep = rec(i + 1, horses); long long sell = y[i] * horses; dp[{i, horses}] = max(sell, keep) % MOD; return max(sell, keep) % MOD; } int init(int N, int X[], int Y[]) { n = N; for (int i = 0; i < n; ++i) { x[i] = X[i]; y[i] = Y[i]; } return rec(0, 1); } int updateX(int pos, int val) { dp.clear(); x[pos] = val; return rec(0, 1); } int updateY(int pos, int val) { dp.clear(); y[pos] = val; return rec(0, 1); }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:35:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |  return rec(0, 1);
      |         ~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:41:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   41 |  return rec(0, 1);
      |         ~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:47:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   47 |  return rec(0, 1);
      |         ~~~^~~~~~
#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...