1121C - System Testing - CodeForces Solution


implementation *1600

Please click on ads to support us..

C++ Code:

#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
double l[1500];
double r[1500];
int main() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n), t(k, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ptr = 0;
    int s = 0;
    while (ptr < n) {
        for (int j = 0; j < k && ptr < n; ++j) {
            if (t[j] != 0) {
                t[j]--;
            }
            if (t[j] == 0) {
                t[j] = a[ptr];
                l[ptr] = s;
                r[ptr] = s + a[ptr];
                ptr++;
            }
        }
        s++;
    }
    vector <int> tm;
    for (int i = 0; i < n; ++i)
        tm.push_back(r[i]);
    sort(tm.begin(), tm.end());
    set <int> ans;
    double zn = n;
    for (int i = 0; i < n; ++i) {
        int test = 1;
        for (int j = l[i]; j < r[i]; ++j) {
            double cnt = 0;
            for (int k = 0; k < tm.size(); ++k) {
                if (tm[k] > j)
                    break;
                cnt++;
            }
            double ch = round(100 * (cnt / zn));
            if (ch == test) {
                ans.insert(i);
            }
            ++test;
        }
    }
    cout << ans.size();
}


Comments

Submit
0 Comments
More Questions

169B - Replacing Digits
171D - Broken checker
380C - Sereja and Brackets
1281B - Azamon Web Services
1702A - Round Down the Price
1681C - Double Sort
12A - Super Agent
1709A - Three Doors
1680C - Binary String
1684B - Z mod X = C
1003A - Polycarp's Pockets
1691B - Shoe Shuffling
1706A - Another String Minimization Problem
1695B - Circle Game
1702B - Polycarp Writes a String from Memory
1701A - Grass Field
489C - Given Length and Sum of Digits
886B - Vlad and Cafes
915A - Garden
356A - Knight Tournament
1330A - Dreamoon and Ranking Collection
1692B - All Distinct
1156C - Match Points
1675A - Food for Animals
1328C - Ternary XOR
1689A - Lex String
1708B - Difference of GCDs
863A - Quasi-palindrome
1478A - Nezzar and Colorful Balls
1581B - Diameter of Graph