제출 #125267

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
1252672019-07-05 02:32:21dragonslayeritMountains (IOI17_mountains)C++14
100 / 100
123 ms29944 KiB
#include "mountains.h"
#include <vector>
#include <algorithm>
#include <cstdio>
int memo[2001][2001];
int last[2001][2001];
int solve(int begin,int end){
if(begin==end) return 0;
if(end-begin==1) return 1;
if(memo[begin][end]!=-1) return memo[begin][end];
int ans=solve(begin,last[begin][end-1])+solve(last[begin][end-1]+1,end);
return memo[begin][end]=std::max(ans,solve(begin+1,end));
}
int maximum_deevs(std::vector<int> y) {
for(int i=0;i<=y.size();i++){
for(int j=0;j<=y.size();j++){
memo[i][j]=-1;
}
}
for(int i=0;i<y.size();i++){
int k=i+1;
for(int j=i+1;j<y.size();j++){
if(1LL*(k-i)*(y[j]-y[i])>=1LL*(j-i)*(y[k]-y[i])){
k=j;
}
last[i][j]=k;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:18:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<=y.size();i++){
               ~^~~~~~~~~~
mountains.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<=y.size();j++){
                 ~^~~~~~~~~~
mountains.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<y.size();i++){
               ~^~~~~~~~~
mountains.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=i+1;j<y.size();j++){
                   ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...