Beispiel #1
0
        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;

            long[] a_n = cin.ReadLongArray(n);

            Console.WriteLine(a_n.Sum() - n);
        }
Beispiel #2
0
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var X = cin.ReadLong;
            var m = cin.ReadLongArray(N);

            var nokori = X - m.Sum();
            var ans    = nokori / m.Min() + m.Length;

            WriteLine(ans);
        }
Beispiel #3
0
        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;

            long[] a_n = cin.ReadLongArray(n);
            Array.Sort(a_n);
            Array.Reverse(a_n);

            Dictionary <long, long> dict = new Dictionary <long, long>();

            foreach (long a in a_n)
            {
                if (!dict.ContainsKey(a))
                {
                    dict.Add(a, 0);
                }
                dict[a]++;
            }

            long ans = 0;

            foreach (long a in a_n)
            {
                if (dict[a] == 0)
                {
                    continue;
                }

                dict[a]--;

                long powered = 1;
                while (powered <= a)
                {
                    powered <<= 1;
                }

                long b = powered - a;
                if (dict.ContainsKey(b) && dict[b] > 0)
                {
                    dict[b]--;
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }