# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80031 | 2018-10-18T11:02:19 Z | pzdba | Doktor (COCI17_doktor) | C++14 | 123 ms | 132096 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int a[500005]; int pref[500005], suff[500005]; map<int, int> dp[3000005]; map<int, pii> dp2[3000005]; map<int, int>::iterator its; int main(){ int n; scanf("%d", &n); for(int i=1;i<=n;i++){ scanf("%d", &a[i]); if(i == a[i]) pref[i] = 1; pref[i] += pref[i-1]; } for(int i=n;i>=1;i--){ if(i == a[i]) suff[i] = 1; suff[i] += suff[i+1]; } int ans = 0; for(int i=1;i<=n;i++){ int diff = a[i]-i; if(diff == 0) ans++; int s = 0, e = 0; if(diff < 0) s = i+diff, e = i; else s = i, e = i+diff; int le = e-s+1; diff += 2*i; diff += 1000000; dp[diff][le]++; dp2[diff][le] = pii(s, e); } int st = a[1], en = a[1]; for(int i=0;i<=3000000;i++){ int sum = 0; for(its = dp[i].begin();its != dp[i].end();its++){ sum += its->second; int s = dp2[i][its->first].first; int e = dp2[i][its->first].second; if(ans < sum + pref[s-1] + suff[e+1]){ ans = sum + pref[s-1] + suff[e+1]; st = s; en = e; } } } printf("%d %d\n", a[st], a[en]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 112 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 115 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 102 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 102 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 121 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 108 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 100 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 114 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 103 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 123 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |