Submission #1084908

#TimeUsernameProblemLanguageResultExecution timeMemory
1084908PakinDioxideRice Hub (IOI11_ricehub)C++17
68 / 100
1053 ms3024 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int l = 1, r = 0; vector <pair <int, int>> p; long long recal() { long long sum = 0; int ll = l, rr = r; while (ll < rr) sum += p[rr--].first - p[ll++].first; return sum; } int besthub(int n, int m, int a[], long long x) { p.emplace_back(0, 0); for (int j = 0; j < n; j++) { int i = a[j]; p.emplace_back(i, p[p.size()-1].second + 1); // if (p[p.size()-1].first != i) p.emplace_back(i, p[p.size()-1].second + 1); // else p[p.size()-1].second++; } // for (auto [x, y] : p) printf("%d %d\n", x, y); // printf("S %d\n", p.size()); int mx = 0; while (r < p.size() - 1) { r++; while (recal() > x) l++; mx = max(mx, p[r].second - p[l-1].second); // printf("MX %d\n", mx); } return mx; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (r < p.size() - 1) {
      |            ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...