C: ๆฐใ3ใค้ธใถใใณ - AtCoder Beginner Contest 028 | AtCoder
ใใใใๅใ \(5 \times 4 \times 3\) ้ใใชใฎใงใใใใๅ จ้จๅๆ
vector<int> xs(5); cin >> xs;
vector<int> s;
rep (i, 5) rep (j, i) rep (k, j) s.push_back(xs[i] + xs[j] + xs[k]);
ใฝใผใใใฆใ้่คใๅใ้คใใฆใ3็ช็ฎใๅฎ้ใซๅบๅใใ.
ๅใใไธใฎใใใซใใ.
std::unique
ใจใใใใฎใฎๅญๅจใ็ฅใใชใใฃใใฎใงใ่ปฝใใฐใฐใฃใ.
sort
ใใฆใใไฝฟใใใฎใฎใใใชใฎใง (Unix ใฎ uniq
ใณใใณใใจๅใใ ):
sort(begin(xs), end(xs));
unique(begin(xs), end(xs));
reverse(begin(xs), end(xs));
cout << xs[2] << endl;
ใชใใใใฐใฃใ (Submission #479383).
ใจใใใใใงใใใใกใใฃใจ่ฉณใใ่ชฟในใใใจใซใใ. (่ปฝใ่ชฟในใใใจใฏใใฐใฐใฃใๆค็ดข็ตๆใใผใธใ่ฆใใใจใงใใฃใฆใใใใซ่ฉฒๅฝใฎใใผใธใ่ชญใใใจใงใฏใชใ).
ใๆซๅฐพใซใดใใๆฎใใ็ถๆ
ใใ reverse
ใใใฎใ ใใใ ใดใใ่ฆใฆๅ็ญใใฆใใใจใซใชใ.
ใใฎใใผใธใซใใใใใซใerase
ใใใจใใๆญฃ็ญ (Submission #479557)
ใใใใชใใฐใreverse
ใใฆใใ unique
ใใใฐใใใฃใใใใ (check Submission #480275).
ใใ่ใใใจใๅ
ฅๅใฏ็ธ็ฐใชใ5ใคใงใใฃใใฎใงใ ๅใ้่คใใใซๆฑใใฆใใฐใunique
ใจใ่ฆใใชใใฃใ.
ใใจใๅ จๅๆใใใพใงใใชใใไธ็ช็ฎใฎๅใฏ้ซใ ไบ้ใใ ใฃใ:
\(A<B<C<D<E\)ใซใคใใฆ
sed 's/.*/&\n&/' |
awk 'NR==1{print $2+$3+$5} NR==2{print $1+$4+$5}' |
sort -n | tail -1