제출 #1172989

#제출 시각아이디문제언어결과실행 시간메모리
1172989bebebebeRabbit Carrot (LMIO19_triusis)C++20
컴파일 에러
0 ms0 KiB
// // Created by Bryant Yu on 3/23/25. // #include <iostream> #include <climits> #include <iterator> using namespace std; int main() { int n,m; cin >> n >> m; int arr[n+1]; arr[0] = 0; for (int i=1;i<=n; i++) { int a; cin >> a; a -= i * m; arr[i]=-a; } //jump height max 0 //since changing height of pillars does not change jump height (pillar change all happens before move) //this means path is nonincreasing //find longest decreasing path , i.e. longest nonincreasing subarray //dp[length] = value of the smallest end number of a nonincreasing subarray with legnth length. vector<int> dp; for (int i : arr) { int pos = upper_bound(dp.begin(), dp.end(), i) - dp.begin(); if (pos == dp.size()) { // we can have a new, longer increasing subsequence! dp.push_back(i); } else { // oh ok, at least we can make the ending element smaller if (pos != 0) { dp[pos] = i; } } } int ans = n+1-dp.size(); cout<<ans; //add 1 to ans if 0 isn't part of the sequence }

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

triusis.cpp: In function 'int main()':
triusis.cpp:26:5: error: 'vector' was not declared in this scope
   26 |     vector<int> dp;
      |     ^~~~~~
triusis.cpp:7:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    6 | #include <iterator>
  +++ |+#include <vector>
    7 | 
triusis.cpp:26:12: error: expected primary-expression before 'int'
   26 |     vector<int> dp;
      |            ^~~
triusis.cpp:28:31: error: 'dp' was not declared in this scope
   28 |         int pos = upper_bound(dp.begin(), dp.end(), i) - dp.begin();
      |                               ^~
triusis.cpp:39:19: error: 'dp' was not declared in this scope
   39 |     int ans = n+1-dp.size();
      |                   ^~