| 提出番号 | 929 |
|---|---|
| 提出者 | littlegirl112 |
| 言語 | C++ |
| 提出日時 | 2017-08-01 15:51:15 |
| 問題名 | (28)いつだって一位の男、olphe君 |
| 結果 | WA |
| 点数 | 0% |
| テストケース | 結果 | 得点 | 実行時間 | メモリ使用量 |
|---|---|---|---|---|
| 1 | WA | 0% | 2ms | 7776KB |
| 2 | WA | 0% | 2ms | 8304KB |
| 3 | WA | 0% | 1ms | 7792KB |
| 4 | WA | 0% | 1ms | 7760KB |
| 5 | WA | 0% | 1ms | 8000KB |
| 6 | WA | 0% | 1ms | 8320KB |
| 7 | WA | 0% | 1ms | 7984KB |
| 8 | WA | 0% | 1ms | 7520KB |
| 9 | WA | 0% | 1ms | 8304KB |
| 10 | AC | 100% | 1ms | 7520KB |
| 11 | WA | 0% | 1ms | 8320KB |
| 12 | WA | 0% | 2ms | 7504KB |
| 13 | AC | 100% | 1ms | 8288KB |
| 14 | WA | 0% | 1ms | 8320KB |
| 15 | AC | 100% | 2ms | 8320KB |
| 16 | AC | 100% | 2ms | 7712KB |
| 17 | WA | 0% | 2ms | 7664KB |
| 18 | WA | 0% | 2ms | 8320KB |
| 19 | WA | 0% | 1ms | 7664KB |
| 20 | AC | 100% | 2ms | 8320KB |
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int n, p[1000], s, yan;
int b = 50000000000;
int c = 0;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
cin >> s;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (p[i] > p[j]) {
yan = p[i];
p[i] = p[j];
p[j] = yan;
}
}
}
if (s == 0) {
cout << p[0] << endl;
return 0;
}
for (int i = n - 1; i >= 0;i=i-1) {
if (p[i] >= s) {
b = p[i];
}
else {
c += p[i];
if (c >= s) {
if (b >= c&&c >= s) {
cout << c << endl;
}
else {
if (b >= c&&c <= s) {
cout << b << endl;
}
else {
if (c >= b&&b >= s) {
cout << b << endl;
}
else {
cout << c << endl;
}
}
}
}
}
}
}