Submission #74541

#TimeUsernameProblemLanguageResultExecution timeMemory
74541ZZangZZangDoktor (COCI17_doktor)C++17
70 / 100
110 ms24216 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <functional> #include <string> using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f; int a[1010101]; int cnt[1010101]; int fm_idx[1010101]; int main() { int n; scanf("%d", &n); for(int i=0; i<n; i++) { scanf("%d", a+i); } for(int i=0; i<n; i++) { int cur = n - i - 1; int nidx = -i + a[cur] + n; cnt[nidx] += 1; fm_idx[nidx] = max(fm_idx[nidx], cur); } int ans = 0; int maxx = 0; for(int i=0; i<2*n + 1; i++) { if(maxx < cnt[i]) { maxx = cnt[i]; ans = i; } } if(ans - n > 0) { int t1, t2; t1 = a[ans - n - 1]; t2 = a[n-1]; printf("%d %d\n", t1, t2); } else { int t1, t2; t1 = a[0]; t2 = a[fm_idx[ans] + a[fm_idx[ans]] - 1]; printf("%d %d\n", t1, t2); } return 0; }

Compilation message (stderr)

doktor.cpp: In function 'int main()':
doktor.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
doktor.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+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...