Submission #80855

#TimeUsernameProblemLanguageResultExecution timeMemory
80855luckyboyDoktor (COCI17_doktor)C++14
60 / 100
1072 ms10216 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 "" using namespace std; int n,a[maxn],b[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); scanf("%d",&n); FOR(i,1,n) { scanf("%d",&a[i]),b[i] = a[i],a[i] += i; sum[i] = sum[i-1] + (b[i] == i); } FOR(i,1,n) { FOR(j,1,2*n) cnt[j] = 0; 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; } } } a[l] -= l; if (l != r) a[r] -= r; printf("%d %d",a[l],a[r]); }

Compilation message (stderr)

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