Submission #53567854
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, x) for (int i = 0; i < (x); i++) int main() { int N; cin >> N; vector<ll> A(N), B(N); rep(i, N) cin >> A[i] >> B[i]; /* 方針: 一番[Bi-Ai]が大きい巨人が一番上に乗り、それ以外の巨人は土台になる。その時の頭の高さは ΣAi + max[Bi-Ai]となる。 */ ll maxHeadSize = 0; // 一番大きな巨人のB-A ll totalSize = 0; // 地面を基準とした頭の高さの最大値 for (int i = 0; i < N; i++) { maxHeadSize = max(maxHeadSize, B[i] - A[i]); totalSize += A[i]; } cout << totalSize + maxHeadSize << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Standing On The Shoulders |
User | ryoh1004 |
Language | C++ 23 (gcc 12.2) |
Score | 300 |
Code Size | 688 Byte |
Status | AC |
Exec Time | 98 ms |
Memory | 6408 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt |
All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 3632 KiB |
sample01.txt | AC | 1 ms | 3476 KiB |
sample02.txt | AC | 1 ms | 3636 KiB |
testcase00.txt | AC | 89 ms | 5984 KiB |
testcase01.txt | AC | 96 ms | 6332 KiB |
testcase02.txt | AC | 91 ms | 6148 KiB |
testcase03.txt | AC | 96 ms | 6280 KiB |
testcase04.txt | AC | 93 ms | 6284 KiB |
testcase05.txt | AC | 96 ms | 6284 KiB |
testcase06.txt | AC | 88 ms | 6072 KiB |
testcase07.txt | AC | 95 ms | 6332 KiB |
testcase08.txt | AC | 95 ms | 6408 KiB |
testcase09.txt | AC | 98 ms | 6328 KiB |
testcase10.txt | AC | 88 ms | 6072 KiB |
testcase11.txt | AC | 95 ms | 6328 KiB |
testcase12.txt | AC | 90 ms | 6064 KiB |
testcase13.txt | AC | 95 ms | 6284 KiB |
testcase14.txt | AC | 95 ms | 6336 KiB |
testcase15.txt | AC | 96 ms | 6264 KiB |
testcase16.txt | AC | 88 ms | 6072 KiB |
testcase17.txt | AC | 96 ms | 6256 KiB |
testcase18.txt | AC | 91 ms | 6044 KiB |
testcase19.txt | AC | 96 ms | 6248 KiB |