제출 #648197

#제출 시각아이디문제언어결과실행 시간메모리
648197jekabsStove (JOI18_stove)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> using namespace std; int main() { int n, k; cin >> n >> k; int t[n]; for(auto &x:t) { cin >> x; } sort(t, t + n); vector <int> atn; int ans = t[n-1] - t[0] + 1; for(int i = 0;i < n;i++) { atn.push_back(t[i] - t[i-1] - 1); } sort(atn.begin(),atn.end(), greater<int>()); for(int i = 0;i < k - 1;i++) { ans-=atn[i]; } cout << ans; return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:14:5: error: 'vector' was not declared in this scope
   14 |     vector <int> atn;
      |     ^~~~~~
stove.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
stove.cpp:14:13: error: expected primary-expression before 'int'
   14 |     vector <int> atn;
      |             ^~~
stove.cpp:18:9: error: 'atn' was not declared in this scope
   18 |         atn.push_back(t[i] - t[i-1] - 1);
      |         ^~~
stove.cpp:20:10: error: 'atn' was not declared in this scope
   20 |     sort(atn.begin(),atn.end(), greater<int>());
      |          ^~~