Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Dec 21, 2021
1 parent 91dac12 commit c5b7281
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions 048.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 048 - I will not drop out (★3)

## 解答

```cpp
#include <iostream>
#include <vector>
#include <algorithm> // std::sort()
#include <functional> // std::greater<>
#include <numeric> // std::reduce()

int main()
{
// N 問, K 分間
int N, K;
std::cin >> N >> K;

std::vector<int> scores;

for (int i = 0; i < N; ++i)
{
// 満点 A 点, 部分点 B 点
int A, B;
std::cin >> A >> B;

// 1 分で得られるスコア
const int s1 = B;
scores.push_back(s1);

// もう 1 分で得られるスコア
const int s2 = (A - B);
scores.push_back(s2);
}

// 大きい順にソート
std::sort(scores.begin(), scores.end(), std::greater<>{});

// 先頭 K 要素の合計を求める (long long 型で求める)
const long long a = std::reduce(scores.begin(), scores.begin() + K, 0LL);

// 解答を出力
std::cout << a << '\n';
}
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ C++17 標準ライブラリの機能を優先して使い、競技プログラ
|[038](https://atcoder.jp/contests/typical90/tasks/typical90_af)|[Large LCM](./038.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/038.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/038.cpp)|オーバーフローに注意|
|[044](https://atcoder.jp/contests/typical90/tasks/typical90_ar)|[Shift and Swapping](./044.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/044.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/044.cpp)|見かけ上の変化をメモ|
|[046](https://atcoder.jp/contests/typical90/tasks/typical90_at)|[I Love 46](./046.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/046.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/046.cpp)|同じ意味のものをまとめて考える|
|048| | | | |
|[048](https://atcoder.jp/contests/typical90/tasks/typical90_av)|[I will not drop out](./048.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/048.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/048.cpp)|上界と下界を見積もる|
|050| | | | |
|052| | | | |
|064| | | | |
Expand Down

0 comments on commit c5b7281

Please sign in to comment.