コード例 #1
0
ファイル: 1323899.cs プロジェクト: qifanyyy/CLCDSA
        public void Solve()
        {
            var cin = new MyInputStream();
            var N   = cin.ri();
            var s   = new int[N];

            for (int i = 0; i < N; ++i)
            {
                s[i] = cin.ri();
            }

            Array.Sort(s);

            var sum = s.Sum();

            if (sum % 10 != 0)
            {
                WriteLine(sum);
                return;
            }
            else
            {
                for (int i = 0; i < N; ++i)
                {
                    if ((sum - s[i]) % 10 != 0)
                    {
                        WriteLine(sum - s[i]);
                        return;
                    }
                }
            }
            WriteLine(0);
        }
コード例 #2
0
ファイル: 1330414.cs プロジェクト: qifanyyy/CLCDSA
        public void Solve()
        {
            var cin = new MyInputStream();
            var N   = cin.ri();
            var A   = cin.ri();
            var B   = cin.ri();
            var h   = new int[N];

            for (int i = 0; i < N; ++i)
            {
                h[i] = cin.ri();
            }

            var diff = A - B;
            Func <long, bool> check = (K) =>
            {
                var k = K;
                for (int i = 0; i < N; ++i)
                {
                    var t = h[i] - B * K;
                    if (t > 0)
                    {
                        k -= (long)Math.Ceiling((double)t / diff);
                    }
                }
                return(k >= 0);
            };

            var r = (long)0;
            var l = (long)1e9;

            for (int i = 0; i < 40; ++i)
            {
                var mid = (l + r) >> 1;
                if (check(mid))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
                //WriteLine($"{r} {l}");
            }
            WriteLine(l);
        }