답안 #91621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91621 2018-12-28T17:01:56 Z model_code Safety (NOI18_safety) C++14
24 / 100
2000 ms 760 KB
#include <cstdlib>
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#define MAX_HEIGHT 5000
using namespace std;
int back_arr[2][MAX_HEIGHT+1];
multiset<int>::iterator its[MAX_HEIGHT+1];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,h;
    cin>>n>>h;
    int* arrprev=back_arr[0];
    int* arrcurr=back_arr[1];
    {
        int x;
        cin>>x;
        for(int j=0;j<=MAX_HEIGHT;++j){
            arrprev[j]=abs(j-x);
        }
    }
    for(int i=1;i<n;++i){
        int x;
        cin>>x;
        multiset<int> st;
        for(int j=0;j<min(MAX_HEIGHT,h);++j)its[j]=st.emplace(arrprev[j]);
        for(int j=0;j<=MAX_HEIGHT;++j){
            if(j+h<=MAX_HEIGHT)its[j+h]=st.emplace(arrprev[j+h]);
            arrcurr[j]=*st.begin();
            arrcurr[j]+=abs(j-x);
            if(j-h>=0)st.erase(its[j-h]);
        }
        swap(arrprev,arrcurr);
    }
    cout<<*min_element(arrprev,arrprev+MAX_HEIGHT+1)<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2059 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 201 ms 460 KB Output is correct
14 Correct 117 ms 376 KB Output is correct
15 Correct 280 ms 632 KB Output is correct
16 Correct 264 ms 376 KB Output is correct
17 Correct 240 ms 504 KB Output is correct
18 Correct 193 ms 376 KB Output is correct
19 Correct 141 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 201 ms 460 KB Output is correct
14 Correct 117 ms 376 KB Output is correct
15 Correct 280 ms 632 KB Output is correct
16 Correct 264 ms 376 KB Output is correct
17 Correct 240 ms 504 KB Output is correct
18 Correct 193 ms 376 KB Output is correct
19 Correct 141 ms 452 KB Output is correct
20 Correct 295 ms 632 KB Output is correct
21 Correct 293 ms 632 KB Output is correct
22 Correct 101 ms 376 KB Output is correct
23 Correct 200 ms 632 KB Output is correct
24 Correct 268 ms 760 KB Output is correct
25 Correct 213 ms 760 KB Output is correct
26 Correct 267 ms 500 KB Output is correct
27 Correct 131 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 201 ms 460 KB Output is correct
14 Correct 117 ms 376 KB Output is correct
15 Correct 280 ms 632 KB Output is correct
16 Correct 264 ms 376 KB Output is correct
17 Correct 240 ms 504 KB Output is correct
18 Correct 193 ms 376 KB Output is correct
19 Correct 141 ms 452 KB Output is correct
20 Correct 295 ms 632 KB Output is correct
21 Correct 293 ms 632 KB Output is correct
22 Correct 101 ms 376 KB Output is correct
23 Correct 200 ms 632 KB Output is correct
24 Correct 268 ms 760 KB Output is correct
25 Correct 213 ms 760 KB Output is correct
26 Correct 267 ms 500 KB Output is correct
27 Correct 131 ms 380 KB Output is correct
28 Correct 1389 ms 480 KB Output is correct
29 Correct 1002 ms 504 KB Output is correct
30 Execution timed out 2054 ms 672 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Incorrect 4 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 636 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Incorrect 4 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -