RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0677

Photoshoot

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
1
맞았습니다!!
2
제출 수
50.0%
정답률
레이팅

의견: 0

설명

Farmer John is looking at his cows in a magical field and wants to take pictures
of subsets of his cows.

The field can be seen as a \(N \times N\) grid \((1 \leq N \leq 500)\), with a
single stationary cow at each location. Farmer John's camera is capable of
taking a picture of any \(K \times K\) square that is part of the field
\((1 \leq K \leq \min(N, 25))\).

At all times, each cow has a beauty value between \(0\) and \(10^6\). The
attractiveness index of a picture is the sum of the beauty values of the cows
contained in the picture.

The beauty value for every cow starts out as \(0\), so the attractiveness index of
any picture in the beginning is \(0\).

At \(Q\) times \((1 \leq Q \leq 3\cdot 10^{4})\), the beauty of a single cow will
increase by a positive integer due to eating the magical grass that is planted
on Farmer John's field.

Farmer John wants to know the maximum attractiveness index of a picture he can
take after each of the \(Q\) updates.

Problem credits: Brian Law and Cici Liu

제약

SCORING

  • Inputs 3-6: \(N \leq 50, Q \leq 100\)
  • Inputs 7-10: \(N \leq 50\)
  • Inputs 11-18: No additional constraints.

Problem credits: Brian Law and Cici Liu

입력 형식

The first line contains integers \(N\) and \(K\).

The following line contains an integer \(Q\).

Each of the following \(Q\) lines contains three integers: \(r\), \(c\), and \(v\),
which are the row, column, and new beauty value, respectively
(\(1 \leq r, c \leq N, 1 \leq v \leq 10^6\)). It is guaranteed that the new beauty
value is greater than the beauty value at that location before.

출력 형식

Output \(Q\) lines, corresponding to the maximum attractiveness index of a picture
after each update.

예제 1
입력
4 2
3
2 2 11
3 4 3
3 1 100
출력
11
11
111
설명

After the first update, a picture with the maximum attractiveness index is the
picture with upper left corner \((2, 2)\) and lower right corner \((3, 3)\), which
has an attractiveness index of \(11 + 0 + 0 + 0 = 11\).

The second update does not affect the maximum attractiveness index.

After the third update, the picture with the maximum attractiveness index
changes to the picture with upper left corner \((2, 1)\) and lower right corner
\((3, 2)\), which has an attractiveness index of \(0 + 11 + 100 + 0 = 111\).

예제 2
입력
3 1
3
2 2 3
2 2 5
2 2 7
출력
3
5
7
설명

There is only one cow with a positive beauty value, so the maximum
attractiveness index will always include that cow.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > First Contest > Bronze

태그

평가 및 의견

Photoshoot

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Photoshoot

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8