제출 #212051

#제출 시각아이디문제언어결과실행 시간메모리
212051PeppaPig새로운 문제 (POI13_tak)C++14
100 / 100
194 ms13700 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 5e5+5; long m, d; int n; vector<long> vec; int main() { scanf("%lld %lld %d", &m, &d, &n); for(int i = 1; i <= n; i++) { long a; scanf("%lld", &a); vec.emplace_back(a); } sort(vec.begin(), vec.end(), greater<long>()); int idx = upper_bound(vec.begin(), vec.end(), m - d, greater<long>()) - vec.begin() - 1; if(idx < 0) return !printf("0\n"); long pos = 0; for(int i = 0; i < idx; i++) { pos += max(0ll, vec[i] - abs(d - pos)); if(pos >= m) return !printf("%d\n", i + 1); } if(pos + max(0ll, vec[idx] - abs(d - pos)) >= m) return !printf("%d\n", idx + 1); for(int i = idx + 1; i < n; i++) { pos += max(0ll, vec[i] - abs(d - pos)); if(pos + max(0ll, vec[idx] - abs(d - pos)) >= m) return !printf("%d\n", i + 1); } printf("0\n"); return 0; }

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

tak.cpp: In function 'int main()':
tak.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %d", &m, &d, &n);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
tak.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a);
         ~~~~~^~~~~~~~~~~~
#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...