제출 #639854

#제출 시각아이디문제언어결과실행 시간메모리
639854a_aguiloGlobal Warming (CEOI18_glo)C++14
10 / 100
111 ms1976 KiB
#include<bits/stdc++.h> using namespace std; int n, x, HI; int binarySearch(int x, vector<int>& V, int d){ int hi = V.size()-1; int lo = 0; while(hi >= lo){ int mid = lo + (hi - lo)/2; if((V[mid]-d) < x) lo = mid+1; else hi = mid-1; } return lo; } int main(){ cin >> n >> x; vector<int> nums(n); for(int i = 0; i < n; ++i) cin >> nums[i]; vector<vector<int>> dp(2, vector<int>(1)); dp[0][0] = nums[0]; dp[1][0] = nums[0]; for(int i = 1; i < nums.size(); ++i){ int pos = binarySearch(nums[i], dp[0], x); if(pos == dp[1].size()){ dp[1].push_back(nums[i]); } else dp[1][pos] = min(dp[1][pos],nums[i]); pos = binarySearch(nums[i], dp[0], 0); if(pos == dp[0].size()){ dp[0].push_back(nums[i]); } else dp[0][pos] = nums[i]; //cout << i <<" " << pos << endl; pos = binarySearch(nums[i], dp[1], 0); if(pos == dp[1].size()){ dp[1].push_back(nums[i]); } else dp[1][pos] = min(dp[1][pos], nums[i]); } cout << max(dp[0].size(), dp[1].size()) << endl; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i = 1; i < nums.size(); ++i){
      |                    ~~^~~~~~~~~~~~~
glo.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if(pos == dp[1].size()){
      |            ~~~~^~~~~~~~~~~~~~~
glo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(pos == dp[0].size()){
      |            ~~~~^~~~~~~~~~~~~~~
glo.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(pos == dp[1].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...
#Verdict Execution timeMemoryGrader output
Fetching results...