# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95945 | Retro3014 | Skyscraper (JOI16_skyscraper) | C++17 | 18 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_N 100
#define DIV 1000000007LL
int N;
vector<int> v;
ll ans;
bool chk[MAX_N+1];
int arr[MAX_N+1];
ll L, L2;
int zero(int x){
return (x>0?x:-x);
}
void dfs(int x){
if(x==N){
if(L>=L2){
ans++;
return;
}
}else{
for(int i=0; i<N; i++){
if(!chk[i]){
arr[x] = i;
chk[i] = true;
if(x!=0){
L2+=(ll)zero(v[arr[x]]-v[arr[x-1]]);
}
dfs(x+1);
chk[i] = false;
if(x!=0){
L2-=(ll)zero(v[arr[x]]-v[arr[x-1]]);
}
arr[x] = 0;
}
}
}
}
void solve1(){
dfs(0);
return;
}
void solve2(){
return;
}
int main(){
scanf("%d%lld", &N, &L);
for(int i=0; i<N; i++){
int x; scanf("%d", &x); v.push_back(x);
}
if(N<=8){
solve1();
}else{
solve2();
}
printf("%lld", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |