[PYTHON] AtCoder Grand Contest 041 Participation Report

AtCoder Grand Contest 041 Participation Report

AGC041A - Table Tennis Training

Break through in 28 and a half minutes. WA5. I thought it was easy and submitted it, but it wasn't easy.

The earliest of the following is the answer

  1. Get closer straight (but only if the distance is even, as you will pass each other if the distance is not even)
  2. Meet at 1.
  3. Meet at N.
  4. Two people head for 1, and the player who arrived first in A stays in 1 for 1 turn (this makes the distance even), and turns back to pick up B.
  5. Two people head for N, the player who was in B who arrives first stays in N for 1 turn (this makes the distance even), turns back and picks up A
N, A, B = map(int, input().split())

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)
print(t)

PS: If you think about it again, you don't need 2 and 3, and if it's an even number, you don't have to think about the pattern that goes to the edge.

N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(min(A, N - B + 1) + (B - A - 1) // 2)

AGC041B - Voting Judges

Break through in 113 minutes. WA5. Eat TLE with Python, eat TLE with PyPy, eat TLE even if rewritten with Go, erase one useless copy of slice, AC, only one heavy test case I went in and was messed up.

Nonetheless, the dance of delight was reincarnated from the state of tears that seemed to be rated full bocco in the 1900s to the splendid 900s.

Since M is the maximum number of votes that can receive one problem, if the current score + M is equal to or higher than the Pth score, it is basically a candidate. However, if there were too many votes, I had to vote for the Pth score, which was very difficult. To be honest, I wrote it properly, but I often went through it. Strictly speaking, there seems to be a hole somewhere ...

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	N := readInt()
	M := readInt()
	V := readInt()
	P := readInt()

	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	p := A[P-1]
	V -= P - 1
	b := A[P-1:]
	for {
		mv := M * V
		for i := 0; i < len(b); i++ {
			t := min(p-b[i], M)
			mv -= t
		}
		if mv > 0 {
			p += (mv + len(b) - 1) / len(b)
		} else {
			break
		}
	}

	result := 0
	for i := 0; i < N; i++ {
		if A[i]+M >= p {
			result++
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

Recommended Posts

AtCoder Grand Contest 041 Participation Report
AtCoder Grand Contest 040 Participation Report
AtCoder Grand Contest 047 Participation Report
AtCoder Beginner Contest 181 Participation Report
AtCoder Beginner Contest 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 154 Participation Report
AtCoder Beginner Contest 166 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest 145 Participation Report
AtCoder Beginner Contest 184 Participation Report
AtCoder Beginner Contest 165 Participation Report
AtCoder Beginner Contest 160 Participation Report
AtCoder Beginner Contest 169 Participation Report
AtCoder Beginner Contest 178 Participation Report
AtCoder Beginner Contest 163 Participation Report
AtCoder Beginner Contest 159 Participation Report
AtCoder Beginner Contest 164 Participation Report
AtCoder Regular Contest 105 Participation Report
AtCoder Beginner Contest 168 Participation Report
AtCoder Beginner Contest 150 Participation Report
AtCoder Beginner Contest 158 Participation Report
AtCoder Beginner Contest 180 Participation Report
AtCoder Regular Contest 104 Participation Report
AtCoder Beginner Contest 156 Participation Report
AtCoder Beginner Contest 162 Participation Report
AtCoder Beginner Contest 157 Participation Report
AtCoder Beginner Contest 167 Participation Report
AtCoder Beginner Contest 179 Participation Report
AtCoder Beginner Contest 182 Participation Report
AtCoder Beginner Contest 146 Participation Report
AtCoder Beginner Contest 152 Participation Report
AtCoder Beginner Contest 155 Participation Report
AtCoder Beginner Contest 174 Participation Report
AtCoder Beginner Contest 171 Participation Report
AtCoder Beginner Contest 149 Participation Report
AtCoder Beginner Contest 148 Participation Report
AtCoder Beginner Contest 188 Participation Report
AtCoder Beginner Contest 170 Participation Report
AtCoder Beginner Contest 187 Participation Report
AtCoder Chokudai Contest 005 Participation Report
AtCoder Beginner Contest 183 Participation Report
AtCoder HHKB Programming Contest 2020 Participation Report
AtCoder Acing Programming Contest 2020 Participation Report
AtCoder Keyence Programming Contest 2020 Participation Report
AtCoder Panasonic Programming Contest 2020 Participation Report
AtCoder Grand Contest 041 Review
AtCoder Library Practice Contest Participation Report (Python)
AtCoder Grand Contest 048 Review
AtCoder Grand Contest 045 Review
AtCoder Grand Contest 044 Review
AtCoder Introduction to Heuristics Contest Participation Report
AtCoder Grand Contest 046 Review
AtCoder Judge System Update Test Contest 202004 Participation Report
AtCoder Beginner Contest # 003 Participation Note
ACL Beginner Contest Participation Report
Atcoder Beginner Contest 146 Participation Diary
AtCoder Sumitomo Mitsui Trust Bank Programming Contest 2019 Participation Report
AtCoder Grand Contest Past Question Challenge 2
AtCoder Grand Contest Past Question Challenge 1
AtCoder Hitachi, Ltd. Social Systems Division Programming Contest 2020 Participation Report