제출 #629316

#제출 시각아이디문제언어결과실행 시간메모리
629316peti1234송신탑 (IOI22_towers)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int c=100005; int n, t[c], pos; void init(int N, vector<int> sz) { n=N; for (int i=0; i<n; i++) { t[i+1]=sz[i]; if (t[i+1]>t[i]) pos++; } } void lassu(int l, int r, int d) { int ut=t[l]+d, ans=0, id=1; for (int i=l; i<=r; i++) { if (id==1) { ut=max(ut, t[i]); if (ut-t[i]>=d) { ut=t[i]; id=0; ans++; } } else { ut=min(ut, t[i]); if (t[i]-ut>=d) { ut=t[i]; id=1; } } } return ans; } int max_towers(int l, int r, int d) { l++, r++; if (l<=pos && pos<=r && max(t[l], t[r])+d<=t[pos]) return 2; return 1; } /* int main() { int N; vector<int> P; cin >> N; for (int i=0; i<N; i++) { int x; cin >> x; P.push_back(x); } init(N, P); int q; cin >> q; while (q--) { int l, r, d; cin >> l >> r >> d; cout << max_towers(l, r, d) << "\n"; } return 0; } */ /* 7 1 2 6 4 5 3 7 3 1 5 1 1 5 2 1 5 3 */

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

towers.cpp: In function 'void lassu(int, int, int)':
towers.cpp:33:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   33 |     return ans;
      |            ^~~