제출 #26205

#제출 시각아이디문제언어결과실행 시간메모리
26205ExtazyBoat (APIO16_boat)C++14
0 / 100
2000 ms321232 KiB
#include <bits/stdc++.h> using namespace std; const int N = 517; const int TO = 1000000000; const int KEY = 314487923; const int MOD = (1e9) + 7; int n; pair < int, int > a[N]; unordered_map < int, int > it; long long ans; void update(int pos, int val) { for(;pos<=TO;pos+=pos&(pos)) it[pos]+=val,it[pos]%=MOD; } int query(int pos) { long long ans=0; for(;pos>=1;pos-=pos&(-pos)) ans+=it[pos]; return ans%MOD; } int main() { int i,j; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d %d", &a[i].first, &a[i].second); } for(i=1;i<=n;i++) { for(j=a[i].first;j<=a[i].second;j++) ans+=query(j-1)+1; for(j=a[i].first;j<=a[i].second;j++) update(j,1); } ans%=MOD; printf("%lld\n", ans); return 0; }

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

boat.cpp: In function 'int main()':
boat.cpp:28:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
boat.cpp:30:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a[i].first, &a[i].second);
                                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...