제출 #982100

#제출 시각아이디문제언어결과실행 시간메모리
982100vjudge1서열 (APIO23_sequence)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset; int sequence(int n, vector <int> a){ //unos y tres int current = 0, sup = 0, dos = 0; for(int i=0; i<n; i++){ if(a[i] == 1){ if(current+1>=0) { current++; sup++; } else { current=1; sup = 1; } } else current--; ans = max(sup, ans); } sup = current = 0; for(int i=0; i<n; i++){ if(a[i] == 3){ if(current+1>=0) { current++; sup++; } else { current=1; sup = 1; } } else current--; ans = max(sup, ans); } for(int i=0; i<n; i++) if(a[i] == 2) dos++; return max(dos, ans); }

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

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:27:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |             ans = max(sup, ans);
      |             ^~~
      |             abs
sequence.cpp:44:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |             ans = max(sup, ans);
      |             ^~~
      |             abs
sequence.cpp:50:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |         return max(dos, ans);
      |                         ^~~
      |                         abs