# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
799143 |
2023-07-31T10:09:37 Z |
Blagoj |
Watering can (POI13_kon) |
C++17 |
|
4000 ms |
10652 KB |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
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 = (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 = lower_bound(SQE[i].begin(), SQE[i].end(), t[j]) - SQE[i].begin();
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 = lower_bound(SQE[i].begin(), SQE[i].end(), t[j]) - SQE[i].begin();
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 = lower_bound(SQE[i].begin(), SQE[i].end(), K - zers[i]) - SQE[i].begin();
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;
}
Compilation message
kon.cpp: In function 'int dojrzale(int, int)':
kon.cpp:81:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
81 | if (pos < SQE[i].size())ans += ps[i][pos];
| ~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1492 KB |
Output is correct |
2 |
Correct |
8 ms |
1548 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
649 ms |
2520 KB |
Output is correct |
2 |
Correct |
672 ms |
2180 KB |
Output is correct |
3 |
Correct |
201 ms |
2376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
975 ms |
2716 KB |
Output is correct |
2 |
Correct |
2099 ms |
2664 KB |
Output is correct |
3 |
Correct |
492 ms |
2748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2125 ms |
4416 KB |
Output is correct |
2 |
Correct |
1201 ms |
4048 KB |
Output is correct |
3 |
Correct |
651 ms |
3332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4065 ms |
4692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4070 ms |
5440 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4021 ms |
6812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4072 ms |
10652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
10588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |