Submission #463492

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4634922021-08-11 08:57:07kilikumaExam (eJOI20_exam)C++14
12 / 100
16 ms1316 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
int nbEleves; scanf("%d",&nbEleves);
int A[100000+42];
for (int i = 1; i<= nbEleves; i++) {
scanf("%d",&A[i]);
}
vector<int> obstacles;
obstacles.push_back(0);
int objectif;
scanf("%d",&objectif);
for (int i=1;i<=nbEleves; i++) {
if (A[i] > objectif) {
obstacles.push_back(i);
}
}
obstacles.push_back(nbEleves+1);
int maxi = 0;
for (int i=0;i<obstacles.size()-1;i++) {
bool cond =false;
for (int a = obstacles[i]+1; a < obstacles[i+1]; a ++) {
if (A[a] == objectif) cond = true;
}
if (cond ){
maxi += (obstacles[i+1]-obstacles[i]-1);
}
}
cout << maxi << endl;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

exam.cpp: In function 'int main()':
exam.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i=0;i<obstacles.size()-1;i++) {
      |                ~^~~~~~~~~~~~~~~~~~~
exam.cpp:4:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 |   int nbEleves; scanf("%d",&nbEleves);
      |                 ~~~~~^~~~~~~~~~~~~~~~
exam.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d",&A[i]);
      |     ~~~~~^~~~~~~~~~~~
exam.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d",&objectif);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...