제출 #168601

#제출 시각아이디문제언어결과실행 시간메모리
168601GurbanMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define pb push_back #define ss second #define ff first #define N 2000006 #define inf 1000000009 #define ll long long #define mid(a,b) (a+b)/2 using namespace std; int n,a[N],sub,vis[N],pos,mn = 1e9; map<int,int> p; vector <pair<int,int>> v; void fn(int ind,int pr){ if(p[ind] == 0) return; if(vis[p[ind]]) return; if(ind + 1 != p[ind]) sub++; if(ind + 1 != p[ind] and ((a[ind + 1] > a[ind] and a[ind + 1] <= pr) or a[p[ind]] == a[ind + 1])){ vis[ind + 1] = 1; pr = a[ind + 1]; fn(ind + 1,1e9); } fn(p[ind],pr); } int main() { scanf("%d",&n); for(int i = 1;i <= n;i++){ scanf("%d",&a[i]); v.pb({a[i],i}); if(a[i] < mn){ mn = a[i]; pos = i; } } sort(v.begin(),v.end()); for(int i = 0;i < v.size() - 1;i++) p[v[i].ss] = v[i + 1].ss; a[n + 1] = -1e9; sub++; fn(pos,1e9); printf("%d",sub); }

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

money.cpp: In function 'int main()':
money.cpp:43:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i < v.size() - 1;i++)
                ~~^~~~~~~~~~~~~~
money.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
money.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[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...