Submission #932760

# Submission time Handle Problem Language Result Execution time Memory
932760 2024-02-24T07:10:04 Z Sharky Cell Automaton (JOI23_cell) C++17
0 / 100
33 ms 4056 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

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 cnt = 0, prv = pt;
        while (pt < d.size() && d[pt] < t) sum += d[pt], pt++;
        while (pt < d.size() && d[pt] == t) sum += d[pt], cnt++, pt++;
        cout << sum * 2 + 4 * (n - pt) * t + cnt * (t - 1) << '\n';
    }
}

Compilation message

cell.cpp: In function 'int32_t main()':
cell.cpp:25:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         while (pt < d.size() && d[pt] < t) sum += d[pt], pt++;
      |                ~~~^~~~~~~~~~
cell.cpp:26:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while (pt < d.size() && d[pt] == t) sum += d[pt], cnt++, pt++;
      |                ~~~^~~~~~~~~~
cell.cpp:24:22: warning: unused variable 'prv' [-Wunused-variable]
   24 |         int cnt = 0, prv = pt;
      |                      ^~~
# 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 33 ms 4056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 4056 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 1 ms 344 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 -