Created
May 29, 2020 00:58
-
-
Save gbrls/f2ccb2191554001f28c97c0aebb003c4 to your computer and use it in GitHub Desktop.
OBI 2019 calçada imperial https://olimpiada.ic.unicamp.br/pratique/pu/2019/f1/imperial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main() { | |
| int n;cin>>n; | |
| int arr[n]; | |
| int ans=1; | |
| for(int i=0;i<n;i++) cin>>arr[i]; | |
| for(int i=1;i<=n;i++) { | |
| for(int j=1;j<=n;j++) { | |
| if(i!=j) { | |
| int f=0; | |
| int accm=0; | |
| for(int k=0;k<n;k++) { | |
| if(arr[k] == i && f==0) { | |
| accm++;f=1-f; | |
| } | |
| if(arr[k] == j && f==1) { | |
| f=1-f; accm++; | |
| } | |
| } | |
| ans = max(ans,accm); | |
| } | |
| } | |
| } | |
| cout<<ans<<'\n'; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment