제출 #335631

#제출 시각아이디문제언어결과실행 시간메모리
335631JoshcVudu (COCI15_vudu)C++11
42 / 140
322 ms27592 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; #define f first #define s second long long int l[1000001]; int bit[1000001], m[1000001]; int main() { long long int n, p, count=1, ans=0; scanf("%lld", &n); for (int i=1; i<=n; i++) scanf("%lld", &l[i]); scanf("%lld", &p); l[0] = 0; for (int i=1; i<=n; i++) l[i] = l[i-1]+l[i]-p; vector<pair<int, int> > arr; for (int i=0; i<=n; i++) arr.emplace_back(l[i], i); sort(arr.begin(), arr.end()); m[arr[0].s] = 1; for (int i=1; i<=n; i++) { if (arr[i].f != arr[i-1].f) m[arr[i].s] = ++count; else m[arr[i].s] = count; } for (int i=n; i>=0; i--) { for (long long int j=m[i]; j<=n; j+=j&-j) bit[j]++; for (long long int j=m[i]-1; j>0; j-=j&-j) ans += bit[j]; } printf("%lld\n", n*(n+1)/2-ans); }

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

vudu.cpp: In function 'int main()':
vudu.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
vudu.cpp:15:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     for (int i=1; i<=n; i++) scanf("%lld", &l[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~
vudu.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%lld", &p);
      |     ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...