답안 #125264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125264 2019-07-05T02:20:52 Z dragonslayerit Mountains (IOI17_mountains) C++14
0 / 100
2 ms 504 KB
#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((k-i)*(y[j]-y[i])>=(j-i)*(y[k]-y[i])){
	k=j;
      }
      last[i][j]=k;
    }
  }
  return solve(0,y.size());
}

Compilation message

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++){
                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Incorrect 2 ms 504 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Incorrect 2 ms 504 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Incorrect 2 ms 504 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Incorrect 2 ms 504 KB Output isn't correct
8 Halted 0 ms 0 KB -