제출 #122745

#제출 시각아이디문제언어결과실행 시간메모리
122745arnold518Stove (JOI18_stove)C++14
100 / 100
28 ms2296 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, K, T[MAXN+10], ans; int main() { int i, j; scanf("%d%d", &N, &K); K--; for(i=1; i<=N; i++) scanf("%d", &T[i]); ans=T[N]+1-T[1]; vector<int> V; for(i=2; i<=N; i++) if(T[i]>1+T[i-1]) V.push_back(T[i]-T[i-1]-1); sort(V.begin(), V.end(), greater<int>()); for(i=0; i<V.size() && i<K; i++) ans-=V[i]; printf("%d", ans); }

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

stove.cpp: In function 'int main()':
stove.cpp:25:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<V.size() && i<K; i++) ans-=V[i];
              ~^~~~~~~~~
stove.cpp:14:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
stove.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &K); K--;
     ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:17:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &T[i]);
                         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...