Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Domains/CompetitiveProgramming/Programs/C++/AntonAndDanik.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Problem: Anton and Danik
Platform: Codeforces
Problem Code: 734A
Difficulty: Easy (800 rated)
Link: https://codeforces.com/problemset/problem/734/A

Anton likes to play chess, and so does his friend Danik.

Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.

Now Anton wonders, who won more games, he or Danik? Help him determine this.

Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.

The second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.

Output
If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.

If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.

If Anton and Danik won the same number of games, print "Friendship" (without quotes).

Examples:

Input:
6
ADAAAA
Output:
Anton

Input:
7
DDDAADA
Output:
Danik

Input:
6
DADADA
Output:
Friendship

Approach:
1. Calculate the number of A's, and compare it with the number of D's
2. return Anton if A > D and Danik if A < D and Friendship if A = D.

Time Complexity: O(n)
Space Complexity: O(1)

Contributor: SamaKool
*/

#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
string s;
cin >> n;
cin >> s;
int Acnt = 0;
for (int i = 0; i < n; i++){
if(s[i] == 'A') Acnt++;
}
if(Acnt > n - Acnt) cout<<"Anton";
else if(Acnt < n - Acnt) cout<<"Danik";
else cout<<"Friendship";
return 0;
}
Loading