제출 #59948

#제출 시각아이디문제언어결과실행 시간메모리
59948gusfringStove (JOI18_stove)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> const int MAXN = 1e5 + 5; int t[MAXN], a[MAXN], N, K; int main(){ int N, K; scanf("%d %d", &N, &K); for(int i=0; i<n; ++i) scanf("%d", &t[i]); int res = t[n - 1] + 1 - t[0]; for(int i=0; i<n-1; ++i) a[i] = t[i + 1] - t[i] - 1; std::sort(a, a + n - 1, std::greater<int>()); for(int i=0; i<k-1; ++i) res -= a[i]; printf("%d",res); }

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

stove.cpp: In function 'int main()':
stove.cpp:10:17: error: 'n' was not declared in this scope
  for(int i=0; i<n; ++i) scanf("%d", &t[i]);
                 ^
stove.cpp:11:14: error: 'n' was not declared in this scope
  int res = t[n - 1] + 1 - t[0];
              ^
stove.cpp:14:17: error: 'k' was not declared in this scope
  for(int i=0; i<k-1; ++i) res -= a[i];
                 ^
stove.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:10:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; ++i) scanf("%d", &t[i]);
                         ~~~~~^~~~~~~~~~~~~