Submission #36049526


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h.at(i);
    }

    priority_queue<int> p;
    for (int i = 0; i < n; i++) {
        p.push(h.at(i));
    }

    int a = p.top();

    int ans;
    for (int i = 0; i < n; i++) {
        if (h.at(i) == a) {
            ans = i + 1;
            break;
        }
    }

    cout << ans << endl;
}

Submission Info

Submission Time
Task A - Find Takahashi
User Awes
Language C++ (GCC 9.2.1)
Score 100
Code Size 478 Byte
Status AC
Exec Time 5 ms
Memory 3600 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |     cout << ans << endl;
      |             ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 12
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt
Case Name Status Exec Time Memory
example_00.txt AC 5 ms 3492 KiB
example_01.txt AC 2 ms 3416 KiB
example_02.txt AC 2 ms 3416 KiB
hand_00.txt AC 2 ms 3416 KiB
hand_01.txt AC 2 ms 3496 KiB
hand_02.txt AC 2 ms 3592 KiB
random_00.txt AC 4 ms 3468 KiB
random_01.txt AC 2 ms 3552 KiB
random_02.txt AC 3 ms 3424 KiB
random_03.txt AC 2 ms 3496 KiB
random_04.txt AC 4 ms 3600 KiB
random_05.txt AC 2 ms 3520 KiB