Submission #200201

#TimeUsernameProblemLanguageResultExecution timeMemory
200201wilwxkSafety (NOI18_safety)C++14
0 / 100
2096 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 20; int v[MAXN], aux[MAXN], vv[MAXN]; ll ans = 1e18; int n, x; void brute(int id) { if(id == n) { for(int i = 1; i <= n; i++) { vv[i] = v[i]; for(int j = i-1; j >= 1; j--) vv[j] = vv[j+1]+aux[j]; for(int j = i+1; j <= n; j++) vv[j] = vv[j-1]+aux[j]; ll val = 0; for(int i = 1; i <= n; i++) val += abs(vv[i]-v[i]); ans = min(ans, val); } return; } for(int k = -x; k <= x; k++) { aux[id] = k; brute(id+1); } } int main() { scanf("%d %d", &n, &x); for(int i = 1; i <= n; i++) scanf("%d", &v[i]); brute(1); printf("%lld\n", ans); }

Compilation message (stderr)

safety.cpp: In function 'int main()':
safety.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &x);
  ~~~~~^~~~~~~~~~~~~~~~~
safety.cpp:31:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
                              ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...