Submission #80856

#TimeUsernameProblemLanguageResultExecution timeMemory
80856luckyboyDoktor (COCI17_doktor)C++14
60 / 100
1083 ms8188 KiB
/** Lucky Boy **/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pb push_back #define mp make_pair #define F first #define S second #define maxc 1000000007 #define maxn 500005 #define maxm 500005 #define pii pair <int,int> #define Task "" template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');} template <typename T> inline void writeln(T x){write(x);putchar('\n');} using namespace std; int n,a[maxn],cnt[maxn << 1],ans,l,r,sum[maxn]; int main() { //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //freopen(".inp", "r",stdin); read(n); FOR(i,1,n) { read(a[i]); sum[i] = sum[i-1] + (a[i] == i); a[i] += i; } FOR(i,1,n) { FOR(j,i,n) { ++cnt[a[j]]; if (cnt[i+j] + sum[i-1] + sum[n] - sum[j-1] > ans) { ans = cnt[i+j] + sum[i-1] + sum[n] - sum[j-1]; l = i,r = j; } } FOR(j,i,n) cnt[a[j]] = 0; } a[l] -= l; if (l != r) a[r] -= r; write(a[l]); write(a[r]); }
#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...