예제 #1
0
        public void MinimumSegmentTreeTest()
        {
            var data = new int[] { 1, 2, 3, 4, 5 }.Select(i => new MinInt(i)).ToArray();
            var segmentTree = new SegmentTree <MinInt>(data);

            Assert.Equal(1, segmentTree.Query(0..5));
            Assert.Equal(3, segmentTree.Query(2..5));

            segmentTree[4] = new MinInt(0);
            Assert.Equal(0, segmentTree.Query(0..5));
            Assert.Equal(1, segmentTree.Query(0..4));

            segmentTree[^ 4] = new MinInt(-5);
예제 #2
0
 public MinInt Merge(MinInt other) => Value < other.Value ? this : other;