제출 #51937

#제출 시각아이디문제언어결과실행 시간메모리
51937TadijaSebezStove (JOI18_stove)C++11
100 / 100
37 ms10652 KiB
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; const int N=100050; int t[N]; int main() { int n,k,i; scanf("%i %i",&n,&k); for(i=1;i<=n;i++) scanf("%i",&t[i]); sort(t+1,t+1+n); vector<int> del; for(i=2;i<=n;i++) { del.push_back(t[i]-t[i-1]-1); } sort(del.rbegin(),del.rend()); int sol=t[n]-t[1]+1; for(i=0;i<k-1;i++) { sol-=del[i]; } printf("%i\n",sol); return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
stove.cpp:11:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%i",&t[i]);
                    ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...