Submission #95945

#TimeUsernameProblemLanguageResultExecution timeMemory
95945Retro3014Skyscraper (JOI16_skyscraper)C++17
5 / 100
18 ms376 KiB
#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)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &N, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:60:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x); v.push_back(x);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...