Submission #581037

# Submission time Handle Problem Language Result Execution time Memory
581037 2022-06-22T08:39:40 Z AngusWong Snowball (JOI21_ho_t2) C++17
100 / 100
230 ms 8500 KB
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;

ll n, q, x, a[200001], p=0, now=0, mxl=0, mxr=0, ans[200001];
vector<pll> v;

int main() {
    cin >> n >> q;
    for (int i=1; i<=n; i++) cin >> a[i];
    sort(a+1, a+n+1);
    for (int i=1; i<n; i++) v.push_back({a[i+1]-a[i], i});
    sort(v.begin(), v.end());
    while (q--){
        cin >> x;
        now+=x;
        if (now<mxl){
            mxl=now;
            while (p<v.size() && v[p].f<=mxr-mxl){
                ans[v[p].s]+=mxr;
                ans[v[p].s+1]+=v[p].f-mxr;
                p++;
            }
        }
        if (now>mxr){
            mxr=now;
            while (p<v.size() && v[p].f<=mxr-mxl){
                ans[v[p].s]+=v[p].f+mxl;
                ans[v[p].s+1]-=mxl;
                p++;
            }
        }
    }
    while (p<v.size()){
        ans[v[p].s]+=mxr;
        ans[v[p].s+1]-=mxl;
        p++;
    }
    ans[1]-=mxl, ans[n]+=mxr;
    for (int i=1; i<=n; i++) cout << ans[i] << "\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             while (p<v.size() && v[p].f<=mxr-mxl){
      |                    ~^~~~~~~~~
Main.cpp:30:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             while (p<v.size() && v[p].f<=mxr-mxl){
      |                    ~^~~~~~~~~
Main.cpp:37:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     while (p<v.size()){
      |            ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 404 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 404 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 81 ms 296 KB Output is correct
21 Correct 83 ms 308 KB Output is correct
22 Correct 68 ms 300 KB Output is correct
23 Correct 65 ms 384 KB Output is correct
24 Correct 73 ms 1196 KB Output is correct
25 Correct 185 ms 8276 KB Output is correct
26 Correct 182 ms 8272 KB Output is correct
27 Correct 178 ms 7968 KB Output is correct
28 Correct 187 ms 8112 KB Output is correct
29 Correct 175 ms 7880 KB Output is correct
30 Correct 170 ms 7444 KB Output is correct
31 Correct 168 ms 7080 KB Output is correct
32 Correct 156 ms 7072 KB Output is correct
33 Correct 21 ms 1128 KB Output is correct
34 Correct 198 ms 8248 KB Output is correct
35 Correct 184 ms 7980 KB Output is correct
36 Correct 191 ms 8216 KB Output is correct
37 Correct 188 ms 7964 KB Output is correct
38 Correct 196 ms 7964 KB Output is correct
39 Correct 184 ms 8028 KB Output is correct
40 Correct 184 ms 7980 KB Output is correct
41 Correct 100 ms 212 KB Output is correct
42 Correct 159 ms 7036 KB Output is correct
43 Correct 213 ms 8500 KB Output is correct
44 Correct 110 ms 292 KB Output is correct
45 Correct 188 ms 8060 KB Output is correct
46 Correct 221 ms 8416 KB Output is correct
47 Correct 224 ms 8304 KB Output is correct
48 Correct 230 ms 8352 KB Output is correct