제출 #1133214

#제출 시각아이디문제언어결과실행 시간메모리
1133214Halym2007Gift (IZhO18_nicegift)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <int, int> #define dur exit(0) #define dur1 return(0) const int N = 1e6 + 5; ll n, k, a[N]; vector <ll> v; int main () { // freopen ("input.txt", "r", stdin); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; } if (n % k == 0 and a[i] >= 0) { if (a[1] == 0) { cout << "0\n"; return 0; } cout << n / k << "\n"; for (int i = 1; i <= n; ++i) { if (i % k == 1) { cout << "\n"; cout << a[1] << " "; } cout << i << " "; } } else { cout << "-1\n"; } }

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

nicegift.cpp: In function 'int main()':
nicegift.cpp:21:30: error: 'i' was not declared in this scope
   21 |         if (n % k == 0 and a[i] >= 0) {
      |                              ^