Submission #00108
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <bits/stdc++.h> using namespace std; #define int long long template < class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template < class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } signed main(){ int n; cin >> n; vector<pair< int , int >> pp, mm; for ( int i = 0;i < n;i++){ int a; cin >> a; if (a >= 0){ pp.push_back({a, i+1}); } else { mm.push_back({a, i+1}); } } if (mm.size() % 2 == 0){ if (pp.size() != 0){ sort(pp.begin(), pp.end()); cout << pp[0].second << endl; } else { sort(mm.begin(), mm.end()); cout << mm[0].second << endl; } } else { sort(mm.begin(), mm.end()); cout << mm[mm.size()-1].second << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - Product Maximization |
ユーザー名 | ei1719 |
投稿日時 | 2020-04-25 22:33:46 |
言語 | C++14 |
状態 | Accepted |
得点 | 300 |
ソースコード長 | 768 Byte |
最大実行時間 | 79 ms |
最大メモリ使用量 | 2968 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 300 / 300 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 19 ms | 604 KB |
1
|
in02.txt | AC | 21 ms | 704 KB |
1
|
in03.txt | AC | 21 ms | 548 KB |
1
|
in04.txt | AC | 17 ms | 520 KB |
1
|
in05.txt | AC | 18 ms | 496 KB |
1
|
in06.txt | AC | 41 ms | 1364 KB |
1
|
in07.txt | AC | 32 ms | 1476 KB |
1
|
in08.txt | AC | 45 ms | 2248 KB |
1
|
in09.txt | AC | 27 ms | 1208 KB |
1
|
in10.txt | AC | 26 ms | 1012 KB |
1
|
in11.txt | AC | 25 ms | 612 KB |
1
|
in12.txt | AC | 79 ms | 2160 KB |
1
|
in13.txt | AC | 44 ms | 1568 KB |
1
|
in14.txt | AC | 29 ms | 1040 KB |
1
|
in15.txt | AC | 35 ms | 1440 KB |
1
|
in16.txt | AC | 25 ms | 864 KB |
1
|
in17.txt | AC | 57 ms | 2764 KB |
1
|
in18.txt | AC | 58 ms | 2784 KB |
1
|
in19.txt | AC | 42 ms | 1716 KB |
1
|
in20.txt | AC | 51 ms | 2312 KB |
1
|
in21.txt | AC | 52 ms | 2236 KB |
1
|
in22.txt | AC | 56 ms | 2584 KB |
1
|
in23.txt | AC | 59 ms | 2764 KB |
1
|
in24.txt | AC | 21 ms | 528 KB |
1
|
in25.txt | AC | 19 ms | 504 KB |
1
|
in26.txt | AC | 18 ms | 728 KB |
1
|
in27.txt | AC | 20 ms | 700 KB |
1
|
in28.txt | AC | 38 ms | 2968 KB |
1
|
in29.txt | AC | 54 ms | 2900 KB |
1
|
sample01.txt | AC | 31 ms | 664 KB |
1
|
sample02.txt | AC | 26 ms | 636 KB |
1
|