제출 #1303527

#제출 시각아이디문제언어결과실행 시간메모리
1303527nanaseyuzukiMoney (IZhO17_money)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // Kazusa_Megumi #define ll long long #define fi first #define se second #define pii pair<int, int> #define all(a) a.begin(), a.end() using namespace std; const int mn = 1e6 + 5, mod = 1e9 + 7, inf = 2e9; int n, a[mn]; int bit[mn]; void add(int u, int val){ while(u <= n){ bit[u] += val; u += (u & -u); } } int get(int u){ int res = 0; while(u){ res += bit[u]; u -= (u & -u); } return res; } void solve() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; int ptr = 1, res = 1; for(int i = 2; i <= n; i++){ if(a[i - 1] > a[i] || get(a[i]) - get(a[l] - 1) > 0){ while(ptr < i){ add(a[ptr], 1); ptr ++; } res ++; } } cout << res << '\n'; } main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen("Kazuki.INP", "r")) { freopen("Kazuki.INP", "r", stdin); freopen("Kazuki.OUT", "w", stdout); } int t = 1; // cin >> t; while (t--) solve(); return 0; }

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

money.cpp: In function 'void solve()':
money.cpp:38:49: error: 'l' was not declared in this scope
   38 |         if(a[i - 1] > a[i] || get(a[i]) - get(a[l] - 1) > 0){
      |                                                 ^
money.cpp: At global scope:
money.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main() {
      | ^~~~
money.cpp: In function 'int main()':
money.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen("Kazuki.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
money.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen("Kazuki.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~