127B - Canvas Frames - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
l = 105
cnt = [0] * l
for i in a:
    cnt[i] += 1
c = 0
for i in cnt:
    c += i // 2
ans = c // 2
print(ans)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

void Mon_on_da_code() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}


#define ll long long
#define   endl         "\n"
#define   lpi(n)       for(int i=0 ; i<(n) ; i++)
#define   lpj(n)       for(int j=0 ; j<(n) ; j++)
#define   all(v)      ((v).begin()),((v).end())
#define   allr(v)      ((v).rbegin()),((v).rend())
#define   pb           push_back
#define F first
#define S second
#define sz(x) int((x).size())
#define ui unsigned int
typedef vector<int> vi;
typedef vector<ll> vll;

void flow() {
    int n,q;
    int Freq1[101] = {0};
    cin>>n;
    lpi(n) cin>>q , Freq1[q]++;
    double st{};
    lpi(101){
        if(Freq1[i]>=4) {
            st += Freq1[i] / 4;
            Freq1[i] = Freq1[i] % 4;
        }
        if(Freq1[i]>1 and Freq1[i]<=3)
            st+=0.5;
    }
    cout<<int(st);


}

int main() {
    Mon_on_da_code();
    int tt = 1;
    //  cin >> tt;
    while (tt--) {
        flow();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1468C - Berpizza
1546B - AquaMoon and Stolen String
1353C - Board Moves
902A - Visiting a Friend
299B - Ksusha the Squirrel
1647D - Madoka and the Best School in Russia
1208A - XORinacci
1539B - Love Song
22B - Bargaining Table
1490B - Balanced Remainders
264A - Escape from Stones
1506A - Strange Table
456A - Laptops
855B - Marvolo Gaunt's Ring
1454A - Special Permutation
1359A - Berland Poker
459A - Pashmak and Garden
1327B - Princesses and Princes
1450F - The Struggling Contestant
1399B - Gifts Fixing
1138A - Sushi for Two
982C - Cut 'em all
931A - Friends Meeting
1594A - Consecutive Sum Riddle
1466A - Bovine Dilemma
454A - Little Pony and Crystal Mine
2A - Winner
1622B - Berland Music
1139B - Chocolates
1371A - Magical Sticks