Submission #973360

# Submission time Handle Problem Language Result Execution time Memory
973360 2024-05-01T20:16:28 Z Circling Izbori (COCI22_izbori) C++17
40 / 110
67 ms 16464 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int64_t n, a[200000], maxcnt, ans = 0, currcntr = 0;
map<int64_t, int64_t> cnt;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n <= 3000){
        for (int i = 0; i < n; i++){
            maxcnt = 0;
            cnt.clear();
            for (int j = i; j < n; j++){
                cnt[a[j]]++;
                maxcnt = max(maxcnt, cnt[a[j]]);
                if (maxcnt * 2 > j - i + 1) ans++;
            }
        }
        cout << ans;
        return 0;
    }
    cnt[0]++;
    for (int i = 0; i < n; i++){
        currcntr += a[i] * 2 - 3;
        ans += i + 1 - cnt[currcntr];
        cnt[currcntr]++;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 61 ms 512 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 45 ms 500 KB Output is correct
10 Correct 46 ms 476 KB Output is correct
11 Correct 45 ms 344 KB Output is correct
12 Correct 46 ms 344 KB Output is correct
13 Correct 45 ms 480 KB Output is correct
14 Correct 46 ms 348 KB Output is correct
15 Correct 45 ms 348 KB Output is correct
16 Correct 46 ms 348 KB Output is correct
17 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1372 KB Output is correct
2 Correct 13 ms 2176 KB Output is correct
3 Correct 10 ms 1372 KB Output is correct
4 Correct 13 ms 2140 KB Output is correct
5 Correct 13 ms 2180 KB Output is correct
6 Correct 15 ms 2392 KB Output is correct
7 Correct 14 ms 2392 KB Output is correct
8 Correct 14 ms 2396 KB Output is correct
9 Correct 14 ms 2396 KB Output is correct
10 Correct 15 ms 2396 KB Output is correct
11 Correct 57 ms 14876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 61 ms 512 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 45 ms 500 KB Output is correct
10 Correct 46 ms 476 KB Output is correct
11 Correct 45 ms 344 KB Output is correct
12 Correct 46 ms 344 KB Output is correct
13 Correct 45 ms 480 KB Output is correct
14 Correct 46 ms 348 KB Output is correct
15 Correct 45 ms 348 KB Output is correct
16 Correct 46 ms 348 KB Output is correct
17 Correct 7 ms 348 KB Output is correct
18 Correct 12 ms 1372 KB Output is correct
19 Correct 13 ms 2176 KB Output is correct
20 Correct 10 ms 1372 KB Output is correct
21 Correct 13 ms 2140 KB Output is correct
22 Correct 13 ms 2180 KB Output is correct
23 Correct 15 ms 2392 KB Output is correct
24 Correct 14 ms 2392 KB Output is correct
25 Correct 14 ms 2396 KB Output is correct
26 Correct 14 ms 2396 KB Output is correct
27 Correct 15 ms 2396 KB Output is correct
28 Correct 57 ms 14876 KB Output is correct
29 Correct 67 ms 16464 KB Output is correct
30 Incorrect 10 ms 3164 KB Output isn't correct
31 Halted 0 ms 0 KB -