답안 #599922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599922 2022-07-20T09:18:33 Z Piokemon Snowball (JOI21_ho_t2) C++17
33 / 100
2500 ms 3908 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
constexpr ll oo = 4611686018427387904;
ll sniez[200009];
ll wiatr[200009];

ll wynik(ll poz,ll poz1,ll poz2, int q){
    ll lew = poz, praw = poz, lew1 = poz1, praw1 = poz1, lew2 = poz2, praw2 = poz2;
    ll odp = 0;
    for (int x=1;x<=q;x++){
        if (wiatr[x] > 0){
            if (poz2 != oo){
                poz2 += wiatr[x];
                praw2 = max(praw2,poz2);
            }
            

            odp += max(wiatr[x] - (praw1 - poz1) - max(((poz1 + wiatr[x]) - max(lew2,praw1)),0LL),0LL);
            poz1 += wiatr[x];
            praw1 = max(praw1, poz1);

            if (poz != -oo){
                poz += wiatr[x];
                praw = max(praw,poz);
            }
        }
        else{
            if (poz != -oo){
                poz += wiatr[x];
                lew = min(lew,poz);
            }

            odp += max(-wiatr[x] - (poz1 - lew1) - max(praw - (poz1 + wiatr[x]),0LL),0LL);
            poz1 += wiatr[x];
            lew1 = min(lew1, poz1);

            if (poz2 != oo){
                poz2 += wiatr[x];
                lew2 = min(lew2,poz2);
            }
            
        }
    }
    return odp;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin >> n >> q;
    for (int x=1;x<=n;x++){
        cin >> sniez[x];
        sniez[x] += 1'000'000'000'000'000'009;
    }
    sniez[0] = -oo;
    sniez[n+1] = oo;
    for (int x=1;x<=q;x++){
        cin >> wiatr[x];
    }

    for (int x=1;x<=n;x++){
        cout << wynik(sniez[x-1],sniez[x],sniez[x+1],q) << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 12 ms 424 KB Output is correct
5 Correct 13 ms 380 KB Output is correct
6 Correct 14 ms 468 KB Output is correct
7 Correct 12 ms 412 KB Output is correct
8 Correct 13 ms 396 KB Output is correct
9 Correct 12 ms 340 KB Output is correct
10 Correct 11 ms 468 KB Output is correct
11 Correct 12 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 340 KB Output is correct
15 Correct 12 ms 340 KB Output is correct
16 Correct 13 ms 340 KB Output is correct
17 Correct 12 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 11 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 12 ms 424 KB Output is correct
5 Correct 13 ms 380 KB Output is correct
6 Correct 14 ms 468 KB Output is correct
7 Correct 12 ms 412 KB Output is correct
8 Correct 13 ms 396 KB Output is correct
9 Correct 12 ms 340 KB Output is correct
10 Correct 11 ms 468 KB Output is correct
11 Correct 12 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 340 KB Output is correct
15 Correct 12 ms 340 KB Output is correct
16 Correct 13 ms 340 KB Output is correct
17 Correct 12 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 11 ms 340 KB Output is correct
20 Correct 36 ms 3908 KB Output is correct
21 Correct 51 ms 3788 KB Output is correct
22 Correct 258 ms 3620 KB Output is correct
23 Correct 2411 ms 3596 KB Output is correct
24 Execution timed out 2567 ms 3752 KB Time limit exceeded
25 Halted 0 ms 0 KB -