제출 #799152

#제출 시각아이디문제언어결과실행 시간메모리
799152bane새로운 문제 (POI13_kon)C++17
50 / 100
4073 ms8708 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nax = 300'001; int sq = 500; ll N, K, t[nax], zers[nax]; vector<ll>SQE[nax / 500 + 5]; vector<ll>ps[nax / 500 + 5]; void inicjuj(int n, int k, int *D) { sq = min(500, (int)sqrt(n) + 1); for (int i = 0; i < n; i++) { t[i] = D[i]; SQE[i / sq].push_back(t[i]); } N = n, K = k; for (int i = 0; i <= n / sq; i++){ ps[i].resize(SQE[i].size()); sort(SQE[i].begin(), SQE[i].end()); SQE[i].erase(unique(SQE[i].begin(),SQE[i].end()),SQE[i].end()); for (int j = i * sq; j < n && j /sq == i; j++){ int pos = -1; int l = 0, r = (int)SQE[i].size() - 1; while(l <= r){ int mid = (l + r) / 2; if (SQE[i][mid] >= t[j]){ pos = mid; r = mid - 1; }else{ l = mid + 1; } } ps[i][pos]++; } for (int j = ps[i].size() - 2; j >= 0; j--){ ps[i][j] += ps[i][j + 1]; } } } void podlej(int a, int b) { //--a,--b; for (int i = a / sq; i * sq <= b; i++){ // cout << i << endl; if (a <= i * sq && b >= (i + 1) * sq - 1){ zers[i]++; }else{ SQE[i].clear(); for (int j = i*sq; j / sq == i && j < N; j++){ t[j]+=zers[i]; if (j >= a && j <= b)t[j]++; SQE[i].push_back(t[j]); // t[j]++; } zers[i] = 0; sort(SQE[i].begin(), SQE[i].end()); SQE[i].erase(unique(SQE[i].begin(),SQE[i].end()),SQE[i].end()); ps[i].clear(); ps[i].resize(SQE[i].size()); for (int j = i*sq; j / sq == i && j < N; j++){ int pos = -1; int l = 0, r = (int)SQE[i].size() - 1; while(l <= r){ int mid = (l + r) / 2; if (SQE[i][mid] >= t[j]){ pos = mid; r = mid - 1; }else{ l = mid + 1; } } ps[i][pos]++; } for (int j = ps[i].size() - 2; j >= 0; j--){ ps[i][j] += ps[i][j + 1]; } } } } int dojrzale(int a, int b) { // --a,--b; int ans = 0; for (int i = a / sq; i <= b / sq; i++){ if (a <= i * sq && b >= (i + 1) * sq - 1){ int pos = -1; int l = 0, r = (int)SQE[i].size() - 1; while(l <= r){ int mid = (l + r) / 2; if (SQE[i][mid] >= K - zers[i]){ pos = mid; r = mid - 1; }else{ l = mid + 1; } } if (pos < SQE[i].size())ans += ps[i][pos]; }else{ for (int j = max(a, i * sq); j / sq == i && j <= b; j++){ if (t[j] + zers[i] >= K)++ans; } } } return ans; }

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

kon.cpp: In function 'int dojrzale(int, int)':
kon.cpp:107:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |             if (pos < SQE[i].size())ans += ps[i][pos];
      |                 ~~~~^~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...