제출 #785442

#제출 시각아이디문제언어결과실행 시간메모리
785442makanhuliaGlobal Warming (CEOI18_glo)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x, ans; cin >> n >> x; if(x==0) { vector<int> a(n); for(int &p : a) cin >> p; vector<int> dp; int ans=1; for(int p : a) { auto it=lower_bound(dp.begin(), dp.end(), p); if(it==dp.end()) dp.push_back(p); else *it=p; } ans=dp.size(); } else if(x<=5 && n<=50000) { while(n--) { int p; cin >> p; vector<int> tempaa=a; auto it=lower_bound(tempaa.begin(), tempaa.end(), p); if(it==tempaa.end()) tempaa.push_back(p); else *it=p; vector<int> tempba=b; it=lower_bound(tempba.begin(), tempba.end(), p); if(it==tempba.end()) tempba.push_back(p); else *it=p; if(tempaa.size()>tempba.size()) a=tempaa; else a=tempba; p-=x; it=lower_bound(b.begin(), b.end(), p); if(it==b.end()) b.push_back(p); else *it=p; } ans=max(a.size(), b.size()); } else { vector<int> a(n); for(int &p : a) cin >> p; vector<int> dp; int ans=1; for(int i=0; i<n; i++) { dp.clear(); vector<int> temp=a; for(int k=i; k<n; k++) temp[k]+=x; for(int p : temp) { auto it=lower_bound(dp.begin(), dp.end(), p); if(it==dp.end()) dp.push_back(p); else *it=p; } ans=max(ans, (int)dp.size()); } } cout << ans << '\n'; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:9:26: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
    9 |      vector<int> dp; int ans=1;
      |                          ^~~
glo.cpp:19:28: error: 'a' was not declared in this scope
   19 |         vector<int> tempaa=a;
      |                            ^
glo.cpp:23:28: error: 'b' was not declared in this scope
   23 |         vector<int> tempba=b;
      |                            ^
glo.cpp:28:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   28 |         else a=tempba; p-=x;
      |         ^~~~
glo.cpp:28:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   28 |         else a=tempba; p-=x;
      |                        ^
glo.cpp:33:15: error: 'a' was not declared in this scope
   33 |       ans=max(a.size(), b.size());
      |               ^
glo.cpp:33:25: error: 'b' was not declared in this scope
   33 |       ans=max(a.size(), b.size());
      |                         ^