제출 #495596

#제출 시각아이디문제언어결과실행 시간메모리
495596aris12345678Global Warming (CEOI18_glo)C++14
28 / 100
2079 ms3296 KiB
#include<cstdio> #include<climits> #include<algorithm> using namespace std; #define MAXN 200000 #define MAXK 1000000000 #define MAXNUM 1000000000 int A[MAXN], INC[MAXN], DEC[MAXN]; int main() { int K, N; scanf("%d %d\n", &N, &K); for (int i=0; i<N; i++) scanf("%d", &(A[i])); INC[0]=1; for (int i=1; i<N; i++) { INC[i] = 1; for (int j=i-1; j>=0; j--) if (A[i] > A[j]) INC[i] = max(INC[i], 1+INC[j]); } DEC[N-1]=1; for (int i=N-2; i>=0; i--) { DEC[i] = 1; for (int j=i+1; j<N; j++) if (A[i] < A[j]) DEC[i] = max(DEC[i], 1+DEC[j]); } /*for (int i=1; i<N; i++) { INC[i] = max(INC[i], INC[i-1]); printf("%d ", INC[i]); } printf("\n"); for (int i=N-2; i>=0; i--) { DEC[i] = max(DEC[i], DEC[i+1]); printf("%d ", DEC[i]); } printf("\n");*/ int res = 0; for (int i=0; i<N; i++) res = max(res, INC[i]); if (K == 0) { printf("%d\n", res); return 0; } for (int i=0; i<N-1; i++) { for (int j=i+1; j<N; j++) if (A[i] - A[j] < K) { res = max(res, INC[i]+DEC[j]); //printf("%d (%d, %d): %d (%d, %d)\n", i, A[i], A[i+1], res, INC[i], DEC[i+1]); } } printf("%d\n", res); return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d %d\n", &N, &K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     for (int i=0; i<N; i++) scanf("%d", &(A[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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...