Submission #1002674

# Submission time Handle Problem Language Result Execution time Memory
1002674 2024-06-19T17:49:38 Z Andrey Election (BOI18_election) C++14
28 / 100
3000 ms 2176 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,q,l,r;
    cin >> n;
    string s;
    cin >> s;
    vector<int> haha(n+1);
    cin >> q;
    for(int i = 1; i <= n; i++) {
        if(s[i-1] == 'C') {
            haha[i] = 1;
        }
        else {
            haha[i] = -1;
        }
    }
    for(int i = 0; i < q; i++) {
        cin >> l >> r;
        vector<int> bruh(r-l+1);
        for(int j = l; j <= r; j++) {
            bruh[j-l] = haha[j];
        }
        int ans = 0,br = 0;
        for(int j = 0; j < bruh.size(); j++) {
            br+=bruh[j];
            if(br < 0) {
                br++;
                bruh[j] = 0;
                ans++;
            }
        }
        br = 0;
        for(int j = bruh.size()-1; j >= 0; j--) {
            br+=bruh[j];
            if(br < 0) {
                br++;
                bruh[j] = 0;
                ans++;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for(int j = 0; j < bruh.size(); j++) {
      |                        ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 2422 ms 2176 KB Output is correct
7 Execution timed out 3044 ms 1688 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 2422 ms 2176 KB Output is correct
7 Execution timed out 3044 ms 1688 KB Time limit exceeded
8 Halted 0 ms 0 KB -