제출 #931887

#제출 시각아이디문제언어결과실행 시간메모리
931887lovrotStove (JOI18_stove)C++17
0 / 100
1 ms348 KiB
#include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> #include <set> #include <queue> #include <deque> #include <vector> #include <random> #include <chrono> #define X first #define Y second #define PB push_back #define EB emplace_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MOD = 1e9 + 7; // 998 244 353; const int N = 1e5 + 10; int n, k, A[N]; int main() { scanf("%d%d", &n, &k); int lst = 0, ans = 0; for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); A[i] = x - lst - 1; if(!i) ans -= x; if(i == n - 1) ans += x + 1; lst = x; } sort(A + 1, A + n, [](int a, int b) { return a > b; }); for(; k--; ) ans -= A[k]; printf("%d\n", ans); return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...