예제 #1
0
파일: 1836080.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N  = NextInt();
                Li  NG = new Li();

                NG.Add(NextInt());
                NG.Add(NextInt());
                NG.Add(NextInt());
                Func <int, bool> check = (k) =>
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (NG[i] == k)
                        {
                            return(false);
                        }
                    }
                    return(true);
                };

                if (!check(N))
                {
                    "NO".WL();
                    return;
                }
                REP(100, _ =>
                {
                    if (N == 0)
                    {
                        return;
                    }
                    bool flag = true;
                    for (int i = 3; i > 0; i--)
                    {
                        if (N - i < 0)
                        {
                            continue;
                        }
                        flag = check(N - i);
                        if (flag)
                        {
                            N -= i; break;
                        }
                    }
                    if (!flag)
                    {
                        return;
                    }
                });
                if (N == 0)
                {
                    "YES".WL();
                }
                else
                {
                    "NO".WL();
                }
                return;
            }
예제 #2
0
            public void Solve()
            {
                int N    = NextInt();
                Li  list = new Li();

                REP(N, _ =>
                {
                    list.Add(NextInt());
                });
                var tmp = list.OrderBy(_ => _);
                int idx = 0;
                var dix = new Dictionary <int, int>();

                foreach (var item in tmp)
                {
                    if (!dix.ContainsKey(item))
                    {
                        dix.Add(item, idx); idx++;
                    }
                }
                foreach (var item in list)
                {
                    dix[item].WL();
                }
                return;
            }
예제 #3
0
        public static List <int> ReadLineInt(int N)
        {
            var rt = new Li();

            REP(N, _ => rt.Add(ReadInt()));
            return(rt);
        }
예제 #4
0
파일: 1494735.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N = ReadInt();
                Li  s = new Li();

                REP(N, x => s.Add(ReadInt()));
                long sum = s.Sum();

                if (sum % 10 == 0)
                {
                    if (s.Any(x => x % 10 != 0))
                    {
                        var f = s.Where(x => x % 10 != 0).Min();
                        (sum - f).WL();
                    }
                    else
                    {
                        0.WL();
                    }
                }
                else
                {
                    sum.WL();
                }
                return;
            }
예제 #5
0
파일: 1964960.cs 프로젝트: qifanyyy/CLCDSA
        public static IEnumerable <int> ToImos(this IEnumerable <int> ie)
        {
            var        s  = 0;
            List <int> rt = new Li();

            foreach (var item in ie)
            {
                s += item;
                rt.Add(s);
            }
            return(rt);
        }
예제 #6
0
        private void ComputeIntegratedPTC()
        {
            ComputeTransitionProbabilities();

            Wi = ComputeIntegralChar(Ws);
            for (int stream = 0; stream < StreamsCount; stream++)
            {
                Ui.Add(ComputeIntegralChar(Us[stream]));
                Li.Add(ComputeIntegralChar(Ls[stream]));
                Ni.Add(ComputeIntegralChar(Ns[stream]));
            }
        }
예제 #7
0
            public void Solve()
            {
                //ARC087 D FTRobot
                var S = ReadLine().Split('T');
                int X = NextInt(), Y = NextInt();


                var xl = new Li();
                var yl = new Li()
                {
                    0
                };

                S.ForeachWith((i, s) =>
                {
                    if (i % 2 == 0)
                    {
                        xl.Add(s.Length);
                    }
                    else
                    {
                        yl.Add(s.Length);
                    }
                });

                Func <int, Li, bool> dp = (goal, list) =>
                {
                    var set = new HashSet <int>()
                    {
                        list[0]
                    };
                    list.RemoveAt(0);
                    var N = list.Count;
                    N.REP(i =>
                    {
                        var next = new HashSet <int>();
                        foreach (var item in set)
                        {
                            next.Add(item + list[i]);
                            next.Add(item - list[i]);
                        }

                        set = next;
                    });
                    return(set.Contains(goal));
                };

                (dp(X, xl) && dp(Y, yl)?"Yes":"No").WL();

                return;
            }
예제 #8
0
            public void Solve()
            {
                var N = NextInt();
                var P = GetIntList();
                var R = new int[N + 1];

                for (var i = 1; i <= N; i++)
                {
                    R[P[i - 1]] = i;
                }

                var A = new Li();
                var B = new Li();

                for (int i = 1; i <= N; i++)
                {
                    A.Add(30000 * i);
                    B.Add(30000 * (N - i) + R[i]);
                }
                A.JoinWL();
                B.JoinWL();
            }
예제 #9
0
            public void Solve()
            {
                int N    = NextInt();
                var list = new Li();

                N.REP(i => list.Add(NextInt()));
                new ti3(0, N - 1, 1).FOR(i =>
                {
                    if (list[i] % 2 != 1)
                    {
                        return;
                    }
                    if (list[i + 1] <= 0)
                    {
                        return;
                    }
                    list[i]++;
                    list[i + 1]--;
                });

                list.Select(x => (long)x / 2L).Sum().WL();
            }
예제 #10
0
파일: 1892710.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N = NextInt();
                int M = NextInt();

                var graph = new List <Li>();

                REP(N, _ => graph.Add(new Li()));
                REP(M, _ => {
                    int Ai = NextInt(), Bi = NextInt();
                    Ai--;
                    Bi--;
                    graph[Ai].Add(Bi);
                    graph[Bi].Add(Ai);
                });

                for (int i = 0; i < N; i++)
                {
                    var ans = new Li();
                    foreach (var item in graph[i])
                    {
                        if (item == i)
                        {
                            continue;
                        }
                        foreach (var under in graph[item])
                        {
                            if (under == i || under == item || graph[i].Contains(under))
                            {
                                continue;
                            }
                            ans.Add(under);
                        }
                    }
                    ans.Distinct().Count().WL();
                }
                return;
            }
예제 #11
0
파일: 2151930.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N = NextInt();
                var A = new Li();

                N.REP(i => A.Add(NextInt()));

                for (int i = 0; i < N - 1; i++)
                {
                    if (A[i] % 2 == 0)
                    {
                        continue;
                    }
                    if (A[i + 1] <= 0)
                    {
                        continue;
                    }
                    A[i]++;
                    A[i + 1]--;
                }
                A.Select(x => (long)x / 2).Sum().WL();
                return;
            }
예제 #12
0
파일: 2089845.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N = NextInt(), x = NextInt();

                if (x == 1 || x == 2 * N - 1)
                {
                    "No".WL();
                    return;
                }

                if (N == 2)
                {
                    "Yes".WL();
                    new int[] { 1, 2, 3 }.WL();
                    return;
                }

                var range   = Enumerable.Range(1, 2 * N - 1).ToList();
                var section = x == 2 ? new Li {
                    x + 1, x, x - 1, x + 2
                } : new Li {
                    x - 1, x, x + 1, x - 2
                };

                section.ForEach(k => range.Remove(k));

                var ans = new Li();

                var queue = range.ToQueue();

                (N - 2).REP(i => ans.Add(queue.Dequeue()));
                ans.AddRange(section);
                ans.AddRange(queue);
                "Yes".WL();
                ans.WL();
            }