제출 #980759

#제출 시각아이디문제언어결과실행 시간메모리
980759NoMercyDetecting Molecules (IOI16_molecules)C++17
69 / 100
49 ms5580 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<array<int , 2>> v; for (int i = 0;i < w.size();i ++) { v.push_back({w[i] , i}); } sort(v.begin() , v.end()); int lo = 0 , hi = -1 , sum = 0; while (lo < v.size()) { if (hi + 1 < v.size() && sum < l) { sum += v[++ hi][0]; } else if (sum > u) { sum -= v[lo ++][0]; } else { break; } } vector<int> res; if (sum < l || sum > u) { return res; } for (int i = lo;i <= hi;i ++) { res.push_back(v[i][1]); } sort(res.begin() , res.end()); return res; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0;i < w.size();i ++) {
      |                    ~~^~~~~~~~~~
molecules.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while (lo < v.size()) {
      |            ~~~^~~~~~~~~~
molecules.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         if (hi + 1 < v.size() && sum < l) {
      |             ~~~~~~~^~~~~~~~~~
#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...