Submission #132857

#TimeUsernameProblemLanguageResultExecution timeMemory
132857tushar_2658Skyscraper (JOI16_skyscraper)C++14
5 / 100
2078 ms376 KiB
#include "bits/stdc++.h" using namespace std; vector<int> v; int main(int argc, char const *argv[]) { // freopen("in.txt", "r", stdin); int n, m; scanf("%d %d", &n, &m); for(int i=0; i<n; i++){ int x; scanf("%d", &x); v.push_back(x); } int ans = 0; sort(v.begin(), v.end()); do{ int val = 0; for(int i=1; i<(int)v.size(); i++){ val += abs(v[i] - v[i-1]); } if(val <= m)ans += 1; }while(next_permutation(v.begin(), v.end())); cout << ans <<endl; return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main(int, const char**)':
skyscraper.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x); 
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...