답안 #932762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932762 2024-02-24T07:11:22 Z Sharky Cell Automaton (JOI23_cell) C++17
16 / 100
108 ms 14396 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];
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; 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: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], pt++;
      |                ~~~^~~~~~~~~~
cell.cpp:27: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]
   27 |         while (pt < d.size() && d[pt] == t) sum += d[pt], cnt++, pt++;
      |                ~~~^~~~~~~~~~
cell.cpp:25:22: warning: unused variable 'prv' [-Wunused-variable]
   25 |         int cnt = 0, prv = pt;
      |                      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 2268 KB Output is correct
2 Correct 30 ms 4316 KB Output is correct
3 Correct 30 ms 4316 KB Output is correct
4 Correct 29 ms 4316 KB Output is correct
5 Correct 29 ms 4304 KB Output is correct
6 Correct 30 ms 4428 KB Output is correct
7 Correct 32 ms 4312 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 29 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 2268 KB Output is correct
2 Correct 30 ms 4316 KB Output is correct
3 Correct 30 ms 4316 KB Output is correct
4 Correct 29 ms 4316 KB Output is correct
5 Correct 29 ms 4304 KB Output is correct
6 Correct 30 ms 4428 KB Output is correct
7 Correct 32 ms 4312 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 29 ms 4308 KB Output is correct
12 Correct 108 ms 14140 KB Output is correct
13 Correct 98 ms 14188 KB Output is correct
14 Correct 104 ms 14284 KB Output is correct
15 Correct 100 ms 14080 KB Output is correct
16 Correct 63 ms 7288 KB Output is correct
17 Correct 62 ms 7248 KB Output is correct
18 Correct 70 ms 10580 KB Output is correct
19 Correct 102 ms 14396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -