Submission #52132

#TimeUsernameProblemLanguageResultExecution timeMemory
52132EntityITDoktor (COCI17_doktor)C++14
100 / 100
289 ms61624 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 500005; int n, a[N], maxx = -N, pter1, pter2, sum[N]; vector<int> vec[N][2]; signed main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i], sum[i] = sum[i - 1] + (a[i] == i); if ( (a[i] + i) % 2) vec[(a[i] + i) / 2][1].push_back(abs(a[i] - i)); else vec[(a[i] + i) / 2][0].push_back(abs(a[i] - i)); } for (int i = 1; i <= n; ++i) { sort(vec[i][0].begin(), vec[i][0].end() ); sort(vec[i][1].begin(), vec[i][1].end() ); } for (int i = 1; i <= n; ++i) { for (int j = 0; j < vec[i][0].size(); ++j) { int radius = vec[i][0][j]; int res = j + sum[i - radius / 2 - 1] + sum[n] - sum[i + radius / 2]; if (maxx < res) { maxx = res; pter1 = i - radius / 2; pter2 = i + radius / 2; } } } for (int i = 1; i <= n; ++i) { for (int j = 0; j < vec[i][1].size(); ++j) { int radius = vec[i][1][j]; int res = j + sum[i - radius / 2 - 1] + sum[n] - sum[i + radius / 2 + 1]; if (maxx < res) { maxx = res; pter1 = i - radius / 2; pter2 = i + radius / 2 + 1; } } } cout << a[pter1] << ' ' << a[pter2]; return 0; }

Compilation message (stderr)

doktor.cpp: In function 'int main()':
doktor.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < vec[i][0].size(); ++j) {
                         ~~^~~~~~~~~~~~~~~~~~
doktor.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < vec[i][1].size(); ++j) {
                         ~~^~~~~~~~~~~~~~~~~~
#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...