제출 #1315677

#제출 시각아이디문제언어결과실행 시간메모리
1315677vixtorGlobal Warming (NOI13_gw)C11
12 / 40
1097 ms34556 KiB
#include <stdio.h> #include <stdlib.h> #include <limits.h> int flood(int *h, int n, int sea) { int land = 0, cnt = 0; for(int i=0; i<n; i++) { if(h[i]>sea && land == 0) { land = 1; cnt++; } if(h[i]<=sea) land=0; } return cnt; } int pow2(int i) { switch(i) { case 0: return 1; case 1: return 2; case 2: return 4; case 3: return 8; case 4: return 16; case 5: return 32; case 6: return 64; case 7: return 128; } } int main() { int n, *h, cmin=INT_MAX, cmax=0, c, r, i, j, res, resmax=0; char *f; scanf("%d", &n); h = (int *)calloc(n, sizeof(int)); f = (char *)calloc(134217728, sizeof(char)); for(i=0; i<n; i++) { scanf("%d", &h[i]); c = h[i]/8; r = h[i]%8; f[c] = f[c] | pow2(r); if(c>cmax) cmax=c; if(c<cmin) cmin=c; } for(i=cmax; i>=cmin; i--) { if(f[i]!=0) { for(j=7; j>=0; j--) { if(f[i]&pow2(j)) { res = flood(h, n, i*8+j); if(res>resmax) resmax=res; //printf("cu apa la h=%d avem %d insule\n", i*8+j, res); } } } } printf("%d\n", resmax); }

컴파일 시 표준 에러 (stderr) 메시지

gw.c: In function 'main':
gw.c:33:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d", &n);
      |     ^~~~~~~~~~~~~~~
gw.c:37:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf("%d", &h[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...