Submission #799222

# Submission time Handle Problem Language Result Execution time Memory
799222 2023-07-31T10:53:10 Z Blagoj Watering can (POI13_kon) C++17
70 / 100
2694 ms 131072 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <string.h>
#include <bitset>
#include <numeric>
#include <utility>
#include<math.h>
using namespace std;
#define ll long long
const int nax = 300'001;
int sq = 910;
int N, K, t[nax], zers[nax], ans[nax];
 
int mapa[332][300001];
 
void inicjuj(int n, int k, int *D)
{
    //sq = min(550, (int)sqrt(n) + 1);
    for (int i = 0; i < n; i++){
        t[i] = D[i];
    }
    N = n, K = k;
    for (int i = 0; i < n; i++){
        if (K >= t[i] && K - t[i] <= 300000)
            mapa[i / sq][-(K - t[i]) + 300000]++;
        if (t[i] >= K)ans[i / sq]++;
    }
    
}
 
void podlej(int a, int b)
{
    //--a,--b;
    int from = a/sq, to = (b / sq);
    for (int i = from; i <= to; i++){
        if (a <= i * sq && b >= (i + 1) * sq - 1){
            zers[i]++;
            ans[i] += mapa[i][300000 - zers[i]];
        }else{
            ans[i] = 0;
            for (int j = i * sq; j / sq == i && j < N; j++){
                if (K >= t[j] && K - t[j] <= 300000)
                    mapa[i][-(K - t[j]) + 300000]--;
                t[j] += zers[i];
                if (j >= a && j <= b)t[j]++;
                if (K >= t[j] && K - t[j] <= 300000){
                    mapa[i][- (K - t[j]) + 300000]++;
                }
                if (t[j] >= K)ans[i]++;
            }
            zers[i] = 0;
            
        }
    }
}
 
int dojrzale(int a, int b)
{
   // --a,--b;
    int odg = 0;
    int from = a/sq, to = (b / sq);
    for (int i = from; i <= to; i++){
        if (a <= i * sq && b >= (i + 1) * sq - 1){
            odg += ans[i];
        }else{
            for (int j = max(a, i * sq); j / sq == i && j <= b; j++){
                odg += (t[j] + zers[i] >= K);
            }   
        }
    }
    return odg;
}
# Verdict Execution time Memory Grader output
1 Correct 2 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 5 ms 1516 KB Output is correct
2 Correct 14 ms 1548 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 2288 KB Output is correct
2 Correct 321 ms 1936 KB Output is correct
3 Correct 261 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 485 ms 2432 KB Output is correct
2 Correct 581 ms 3712 KB Output is correct
3 Correct 473 ms 2064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1002 ms 113148 KB Output is correct
2 Correct 702 ms 85836 KB Output is correct
3 Correct 642 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 150 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1549 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 424 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2236 ms 17868 KB Output is correct
2 Correct 1764 ms 11388 KB Output is correct
3 Correct 2193 ms 10900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2304 ms 16600 KB Output is correct
2 Correct 2029 ms 15116 KB Output is correct
3 Correct 2694 ms 5548 KB Output is correct