Submission #321082

# Submission time Handle Problem Language Result Execution time Memory
321082 2020-11-10T22:10:29 Z fadi57 Safety (NOI18_safety) C++14
3 / 100
2000 ms 11236 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=200009;
const int mod= 998244353;
const int inf=2*1e5+9;
ll n,h;
ll a[mx];ll c[mx];
bool chek(){
    for(int i=1;i<n;i++){
        if(abs(c[i]-c[i-1])>h){return 0;}
    }
    return 1;
}
int solve(int i){
    if(i==n+1){
        if(chek()){return 0;}else{
            return inf;
        }
    }ll ret=inf;
    for(int j=0;j<=4;j++){
      c[i]=j;  ret=min(ret,solve(i+1)+abs(a[i]-j));
    }
    return ret;
    
}
int main() {
cin>>n>>h;ll sum=0;ll mxx=0;
for(int i=0;i<n;i++){
    cin>>a[i];
    mxx=max(mxx,a[i]);
    
}
cout<<solve(0);

}

Compilation message

safety.cpp: In function 'int main()':
safety.cpp:28:14: warning: unused variable 'sum' [-Wunused-variable]
   28 | cin>>n>>h;ll sum=0;ll mxx=0;
      |              ^~~
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 11236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
8 Execution timed out 2032 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
8 Execution timed out 2032 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
8 Execution timed out 2032 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
8 Execution timed out 2032 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 492 KB Output is correct
2 Correct 912 ms 484 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 913 ms 388 KB Output is correct
5 Correct 917 ms 484 KB Output is correct
6 Correct 91 ms 364 KB Output is correct
7 Correct 452 ms 484 KB Output is correct
8 Execution timed out 2032 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -