//sous-tache 2
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
int nbCandidats, objectif, entree, total = 0, candidatDansIntervalle = 0, candidatsDansIntervalle = 0;
vector<int> candidats;
cin >> nbCandidats;
for (int i = 0; i < nbCandidats; i++)
{
cin >> entree;
candidats.push_back(entree);
}
cin >> objectif;
for (int i = 0; i < nbCandidats; i++)
{
if (candidats[i] == objectif)
{
candidatDansIntervalle = 1;
candidatsDansIntervalle ++;
}
else if (candidats[i] < objectif)
{
candidatsDansIntervalle ++;
}
else
{
total += candidatsDansIntervalle * candidatDansIntervalle;
candidatsDansIntervalle = 0;
candidatDansIntervalle = 0;
}
}
total += candidatsDansIntervalle * candidatDansIntervalle;
candidatsDansIntervalle = 0;
candidatDansIntervalle = 0;
cout << total;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
10 ms |
412 KB |
Output is correct |
3 |
Correct |
29 ms |
852 KB |
Output is correct |
4 |
Correct |
22 ms |
908 KB |
Output is correct |
5 |
Correct |
56 ms |
908 KB |
Output is correct |
6 |
Correct |
19 ms |
840 KB |
Output is correct |
7 |
Correct |
21 ms |
840 KB |
Output is correct |
8 |
Correct |
46 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |