제출 #1298600

#제출 시각아이디문제언어결과실행 시간메모리
1298600minggaMoney (IZhO17_money)C++20
45 / 100
7 ms832 KiB
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "D:/debug.h" #define debug(...) cerr << "\033[35m" << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 240408 #endif #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const ll inf = 2e18; const int N = 1e5 + 7; int n, a[N], id[N]; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; set<pair<int, int>> s; s.insert({a[1], 1}); int ans = 1; id[1] = 1; for(int i = 2; i <= n; i++) { id[i] = i; auto it = s.find(make_pair(a[i - 1], id[i - 1])); debug(i, a[i], (*it)); if((*it).fi > a[i]) { ans++; s.insert({a[i], id[i]}); continue; } it++; if(it == s.end()) { s.insert({a[i], id[i]}); continue; } debug(i, a[i], (*it)); if((*it).fi < a[i]) { ans++; } else if((*it).fi == a[i]) { id[i] = (*it).se - 1; } s.insert({a[i], id[i]}); } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

money.cpp: In function 'int main()':
money.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(task ".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
money.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(task ".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...