제출 #447498

#제출 시각아이디문제언어결과실행 시간메모리
447498aris12345678Exam (eJOI20_exam)C++14
0 / 100
246 ms524292 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5+5; const int mxNumber = 1e9+1; int a[mxN], b[mxN]; bool sub2(int n) { for(int i = 1; i < n; i++) { if(b[i] != b[i-1]) return false; } return true; } int main() { int n; scanf("%d", &n); unordered_map<int, int> mp1; mp1.rehash(mxNumber); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); mp1[a[i]] = i; } for(int i = 0; i < n; i++) scanf("%d", &b[i]); if(sub2(n)) { int i = 0, j = 0, mx = 0, ans = 0; while(j < n) { if(a[j] > b[0] && mx == b[0]) ans += (j-i), mx = 0; while(a[j] > b[0]) j++, i = j; mx = max(mx, a[j++]); } if(mx == b[0]) ans += (j-i); printf("%d\n", ans); } else { int i = 0, ans = 0; while(i < n) { if(a[i] > b[i]) i++; else if(a[i] == b[i]) { ans++, i++; continue; } else { if(mp1.find(b[i]) == mp1.end()) continue; map<int, int> mp2; int res = 0; for(int j = i; j < mp1[b[i]]; j++) { if(a[j] == b[j]) res++; mp2[b[j]]++; } if(mp2.rbegin()->first == b[i]) { ans += mp2[b[i]]; ans += res; i = mp1[b[i]]; } else i++; } } printf("%d\n", ans); } return 0; }

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

exam.cpp: In function 'int main()':
exam.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
exam.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
exam.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...