Skip to content

Commit

Permalink
ABC365B Second Best
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Aug 5, 2024
1 parent 3d971a6 commit 4d0dc6b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions atcoder/abc365b_second_best.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Vicfred
// https://atcoder.jp/contests/abc365/tasks/abc365_b
// greedy, sorting
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
int N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
vector<long long> B = A;
sort(begin(A), end(A));
for(int i = 0; i < N; i++) {
if(B[i] == A[N - 2]) {
cout << i + 1 << endl;
}
}
return 0;
}

0 comments on commit 4d0dc6b

Please sign in to comment.