제출 #474691

#제출 시각아이디문제언어결과실행 시간메모리
474691RafaelSusDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms292 KiB
#include <iostream> #include <vector> #include <algorithm> std::vector<int> find_subset(int l, int r, std::vector<int> a){ std::sort(a.begin(), a.end()); int pl = 0; int pr = 1; long long sum = a[0]; bool ok = true; while(true){ if (pl >= a.size() and pr >= a.size()){ ok = false; break; } if (sum >= l and sum <= r){ break; }else if (sum < l){ pr++; sum += a[pr - 1]; }else if (sum > r){ sum -= a[pl]; pl++; } } if (ok) { std::vector<int> answ; for (int i = pl; i < pr; i++) answ.push_back(i); return answ; }else { std::vector<int> answ; return answ; } } #ifdef TEST int main(){ int l, r; unsigned int n; std::cin >> l >> r >> n; std::vector<int> a(n); for (int i = 0; i < n; i++) std::cin >> a[i]; std::vector<int> answ = find_subset(l, r, a); for (int i = 0; i < answ.size(); i++){ std::cout << answ[i] << ' '; } std::cout << '\n'; } #endif

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         if (pl >= a.size() and pr >= a.size()){
      |             ~~~^~~~~~~~~~~
molecules.cpp:12:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         if (pl >= a.size() and pr >= a.size()){
      |                                ~~~^~~~~~~~~~~
#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...