제출 #1234857

#제출 시각아이디문제언어결과실행 시간메모리
1234857CodeLakVNKralj (COCI16_kralj)C++20
140 / 140
321 ms43296 KiB
#include <bits/stdc++.h> using namespace std; #define task "main" #define no "NO" #define yes "YES" #define F first #define S second #define vec vector #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) const int MAX_N = (int)5e5 + 5; int n; int a[MAX_N], b[MAX_N]; vector<int> here[MAX_N]; int cnt[MAX_N]; void solve() { cin >> n; FOR(i, 1, n) { int idx; cin >> idx; here[idx].push_back(i); cnt[idx]++; } FOR(i, 1, n) cin >> b[i]; FOR(i, 1, n) cin >> a[i]; int startPoint = -1; FOR(i, 1, n - 1) { if (cnt[i] <= 1) { startPoint = i; continue; } cnt[i + 1] += cnt[i] - 1; cnt[i] = 1; } if (cnt[n] <= 1) startPoint = n; startPoint++; if (startPoint > n) startPoint = 1; set<int> s; int i = startPoint, ans = 0; while (true) { for (int j : here[i]) s.insert(a[j]); auto it = s.upper_bound(b[i]); if (it == s.end()) s.erase(s.begin()); else ans++, s.erase(it); i++; if (i > n) i -= n; if (i == startPoint) break; } cout << ans; } int32_t main() { if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool multitest = 0; int numTest = 1; if (multitest) cin >> numTest; while (numTest--) { solve(); } return 0; } /* Lak lu theo dieu nhac!!!! */

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

kralj.cpp: In function 'int32_t main()':
kralj.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kralj.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...