Submission #798624

# Submission time Handle Problem Language Result Execution time Memory
798624 2023-07-30T21:56:33 Z bane Watering can (POI13_kon) C++17
10 / 100
2609 ms 16432 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>
using namespace std;
#define ll long long
const int nax = 300'001;
const int sq = 500;
ll N, K, t[nax], zers[nax];

vector<ll>SQE[500];
vector<ll>ps[500];


void inicjuj(int n, int k, int *D)
{
       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 = max(a,300*i); j / sq == i && j <= b; j++){
                t[j]+=zers[i];
                SQE[i].push_back(t[j] + 1);
                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 = max(a,300*i); j / sq == i && j <= b; 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 * sq <= b; 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 * 300); 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:86:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |             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 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 476 ms 2360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 631 ms 2608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 857 ms 3880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1920 ms 5156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2065 ms 5484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2609 ms 7856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 16084 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 16432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -