Submission #1315654

#TimeUsernameProblemLanguageResultExecution timeMemory
1315654cosminvixtorGlobal Warming (NOI13_gw)C++20
0 / 40
75 ms4288 KiB
#include <iostream>
using namespace std;

void bubble_sort(int *A,int n) {
    int i,chair,done;
    do {
        done=1;
        for (i=1;i<n;i++) {
            if (A[i]>A[i+1]) {
                chair=A[i];
                A[i]=A[i+1];
                A[i+1]=chair;
                done=0;
            }
        }
    } while (!done);
}

int main() {
    int *L,n,i,j,islands,mode,minl,maxl;
    scanf("%d",&n);
    L=(int*)calloc(n+2,sizeof(int));
    scanf("%d",L+1);
    minl=L[1]; maxl=L[1];
    for (i=2;i<=n;i++) {
        scanf("%d",L+i);
        if (L[i]<minl) minl=L[i];
        else if (L[i]>maxl) maxl=L[i];
    }
    islands=0; mode=2; //1=UP 2=DOWN
    for (i=1;i<=n;i++) {
        if (L[i-1]<L[i]) {
            if (mode==2) islands++;
            mode=1;
        } else if (L[i-1]>L[i]) {
            mode=2;
        }
    }
    printf("%d\n",islands+(islands==0));
}

Compilation message (stderr)

gw.cpp: In function 'int main()':
gw.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
gw.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d",L+1);
      |     ~~~~~^~~~~~~~~~
gw.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%d",L+i);
      |         ~~~~~^~~~~~~~~~
#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...