제출 #1228955

#제출 시각아이디문제언어결과실행 시간메모리
1228955adadStove (JOI18_stove)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define TASK "" #define MASK(i) (1<<(i)) #define BIT(x, i) (((x)>>(i))&1) #define int long long #define fi first #define se second using namespace std; const long long INF = 1e17, MOD = 1e9 + 7, maxN = 1e5 + 5; int n, k, t[maxN]; vector <int> tg; signed main() { if (fopen(TASK ".INP", "r")) { freopen(TASK ".INP", "r", stdin); freopen(TASK ".OUT", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for(int i = 1; i <= n; i ++) cin >> t[i]; int ans = t[n] + 1 - t[i]; for(int i = 1; i <= n; i ++) tg.push_back(a[i] - a[i - 1] - 1); sort(tg.rbegin(), tg.rend()); for(int i = 0; i < k and i < tg.size(); i ++) { ans -= tg[i]; } cout << ans; }

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

stove.cpp: In function 'int main()':
stove.cpp:23:28: error: 'i' was not declared in this scope
   23 |     int ans = t[n] + 1 - t[i];
      |                            ^
stove.cpp:24:47: error: 'a' was not declared in this scope
   24 |     for(int i = 1; i <= n; i ++) tg.push_back(a[i] - a[i - 1] - 1);
      |                                               ^
stove.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(TASK ".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(TASK ".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~