제출 #758298

#제출 시각아이디문제언어결과실행 시간메모리
758298KN200711학생 (COCI14_studentsko)C++14
0 / 100
12 ms340 KiB
# include <bits/stdc++.h> using namespace std; int main() { int N, K; scanf("%d %d", &N, &K); vector<int> arr(N), A(N); for(int i=0;i<N;i++) { scanf("%d", &arr[i]); A[i] = arr[i]; } sort(A.begin(), A.end()); int ans = 0; for(int i=0;i<N/K;i++) { int ls = A[N - (i + 1) * K]; int cnt = 0; for(int c=arr.size() - 1;c>=0;c--) { if(arr[c] >= ls) cnt++; else break; } // cout<<i<<" "<<ls<<" "<<cnt<<endl; ans += K - cnt; vector<int> Y; Y.clear(); for(int d=0;d<arr.size();d++) { if(arr[d] < ls) Y.push_back(arr[d]); } arr = Y; } printf("%d\n", ans); }

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

studentsko.cpp: In function 'int main()':
studentsko.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int d=0;d<arr.size();d++) {
      |               ~^~~~~~~~~~~
studentsko.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d %d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~
studentsko.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d", &arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...