Submission #932493

# Submission time Handle Problem Language Result Execution time Memory
932493 2024-02-23T14:03:05 Z Sharky Cell Automaton (JOI23_cell) C++17
0 / 100
23 ms 3292 KB
#include <bits/stdc++.h>
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n), d;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> a[i];
        if (i) d.push_back(a[i] - a[i - 1]);
    }
    int pt = 0, sum = 0;
    sort(d.begin(), d.end());
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            cout << n << '\n';
            continue;
        }
        int ans = 4 * t * n, cnt = 0, prv = pt;
        while (pt < d.size() && d[pt] < t) {
            sum += d[pt], pt++;
            prv = pt;
        }
        while (pt < d.size() && d[pt] == t) cnt++, pt++;
        ans -= (t + 1) * cnt;
        ans -= 2 * (t + 1) * prv;
        sum += cnt * t;
        cout << ans << '\n';
    }
}

Compilation message

cell.cpp: In function 'int32_t main()':
cell.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         while (pt < d.size() && d[pt] < t) {
      |                ~~~^~~~~~~~~~
cell.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         while (pt < d.size() && d[pt] == t) cnt++, pt++;
      |                ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 3292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 3292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -