#31391: 我用vetor兩種方法都TLE...


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
a091. 今晚打老虎 | From: [150.116.71.227] | 發表日期 : 2022-07-27 22:42


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<int> v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<int> v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

 
#31393: Re: 我用vetor兩種方法都TLE...


krameri120 (科科)

學校 : 國立臺南高級工業職業學校
編號 : 102318
來源 : [36.237.212.239]
最後登入時間 :
2024-04-01 14:20:14
a091. 今晚打老虎 | From: [39.8.10.78] | 發表日期 : 2022-07-27 22:46


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

他測資很大

 
#31398: Re: 我用vetor兩種方法都TLE...


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
a091. 今晚打老虎 | From: [150.116.71.227] | 發表日期 : 2022-07-28 11:47


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

他測資很大

那有什麼好方法嗎

 
#31403: Re: 我用vetor兩種方法都TLE...


krameri120 (科科)

學校 : 國立臺南高級工業職業學校
編號 : 102318
來源 : [36.237.212.239]
最後登入時間 :
2024-04-01 14:20:14
a091. 今晚打老虎 | From: [27.246.66.76] | 發表日期 : 2022-07-28 17:40


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

他測資很大

那有什麼好方法嗎

他可能在考map跟優化吧,來刷leetcode吧 bro~
挑主題練會比較好一點,有些題目可能要用些酷酷的方法才會過www

 
#31405: Re: 我用vetor兩種方法都TLE...


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
a091. 今晚打老虎 | From: [150.116.71.227] | 發表日期 : 2022-07-28 18:08


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

他測資很大

那有什麼好方法嗎

他可能在考map跟優化吧,來刷leetcode吧 bro~
挑主題練會比較好一點,有些題目可能要用些酷酷的方法才會過www

好ㄅ

 
#31406: Re: 我用vetor兩種方法都TLE...


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
a091. 今晚打老虎 | From: [150.116.71.227] | 發表日期 : 2022-07-28 18:16


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            cout << *max_element(v.begin(), v.end()) << '\n';
            for (int i = 0; i < v.size(); i++) {
                if (v[i]==*max_element(v.begin(), v.end())){
                    v.erase (v.begin()+i);
                    break;
                }
            }
        }
        else if (t==3){
            cout << *min_element(v.begin(), v.end()) << '\n';
            for (int j = 0; j < v.size(); j++) {
                if (v[j]==*min_element(v.begin(), v.end())){
                    v.erase (v.begin()+j);
                    break;
                }
            }
        }
    }

    return 0;
}// 24%

 

 

 


#include

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector v;
    int t;
    while (cin >> t){
        if (t==1){
            int n;
            cin >> n;
            v.push_back(n);
        }
        else if (t==2){
            sort (v.begin(), v.end());
            cout << v[v.size()-1] << '\n';
            v.erase (v.begin()+(v.size()-1));
        }
        else if (t==3){
            sort (v.begin(), v.end());
            cout << v[0] << '\n';
            v.erase (v.begin()+0);
        }
    }

    return 0;
}// 39%

他測資很大

那有什麼好方法嗎

他可能在考map跟優化吧,來刷leetcode吧 bro~
挑主題練會比較好一點,有些題目可能要用些酷酷的方法才會過www

好ㄅ

可是我有英文障礙



 
ZeroJudge Forum