제출 #603848

#제출 시각아이디문제언어결과실행 시간메모리
603848strange420Detecting Molecules (IOI16_molecules)C++14
69 / 100
43 ms5524 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; bool func(const ii& a, const ii& b) { return a.first < b.first; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<ii> asd; for (int i=0; i<w.size(); i++) asd.push_back(ii(w[i], i)); sort(asd.begin(), asd.end(), func); vector<int> ans; int leftPt = 0, rightPt = 1, sum = asd[0].first; while(true) { if (sum > u) { sum -= asd[leftPt].first; leftPt++; if (leftPt > rightPt) break; } else if (sum < l) { if (rightPt == asd.size()) break; sum += asd[rightPt].first; rightPt++; } else if (l <= sum && sum <=u) { for (int i=leftPt; i<rightPt; i++) ans.push_back(asd[i].second); break; } } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i=0; i<w.size(); i++)
      |                   ~^~~~~~~~~
molecules.cpp:23:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             if (rightPt == asd.size()) break;
      |                 ~~~~~~~~^~~~~~~~~~~~~
#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...