Submission #463492

# Submission time Handle Problem Language Result Execution time Memory
463492 2021-08-11T08:57:07 Z kilikuma Exam (eJOI20_exam) C++14
12 / 100
16 ms 1316 KB
#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; 
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 4 ms 588 KB Output is correct
3 Correct 11 ms 1060 KB Output is correct
4 Correct 10 ms 588 KB Output is correct
5 Correct 15 ms 680 KB Output is correct
6 Correct 12 ms 1316 KB Output is correct
7 Correct 11 ms 676 KB Output is correct
8 Correct 16 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -