Submission #848149

#TimeUsernameProblemLanguageResultExecution timeMemory
848149KN200711Global Warming (CEOI18_glo)C++14
100 / 100
40 ms4064 KiB
# include <bits/stdc++.h> using namespace std; int main() { int N, d; scanf("%d %d", &N, &d); vector<int> arr(N); for(int i=0;i<N;i++) scanf("%d", &arr[i]); vector<int> wo, wi; wo.clear(); wi.clear(); for(int i=0;i<N;i++) { if(wo.size() == 0 || wo.back() < arr[i]) wo.push_back(arr[i]); else { int c = lower_bound(wo.begin(), wo.end(), arr[i]) - wo.begin(); wo[c] = arr[i]; } if(wi.size() == 0 || wi.back() < arr[i] - d) { wi.push_back(arr[i] - d); int p = wi.size(); wo[p - 1] = min(wo[p-1], wi[p-1]); } else { int c = lower_bound(wi.begin(), wi.end(), arr[i] - d) - wi.begin(); wi[c] = arr[i] - d; wo[c] = min(wo[c], wi[c]); } } printf("%d\n", wo.size()); return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:31:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   31 |  printf("%d\n", wo.size());
      |          ~^     ~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
glo.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d %d", &N, &d);
      |  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:8:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
#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...