Submission #47361

#TimeUsernameProblemLanguageResultExecution timeMemory
47361BruteforcemanVrtić (COCI18_vrtic)C++11
32 / 160
3 ms684 KiB
#include "bits/stdc++.h" using namespace std; int a[155]; int c[155]; int n; typedef pair <int, int> pii; int main(int argc, char const *argv[]) { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); } for(int i = 1; i <= n; i++) { scanf("%d", &c[i]); } sort(c + 1, c + n + 1); int ans = 0; for(int i = 1; i <= n-2; i++) { ans = max(ans, c[i + 2] - c[i]); } if(n == 2) ans = max(ans, c[2] - c[1]); printf("%d\n", ans); for(int i = 1; i <= n; i++) { if(i & 1) printf("%d ", c[i]); } for(int i = n; i >= 1; i--) { if(~i & 1) printf("%d ", c[i]); } printf("\n"); return 0; }

Compilation message (stderr)

vrtic.cpp: In function 'int main(int, const char**)':
vrtic.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
vrtic.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
vrtic.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c[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...
#Verdict Execution timeMemoryGrader output
Fetching results...