# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224584 | 2020-04-18T13:00:30 Z | inwbear | Mountains (NOI20_mountains) | C++14 | 2000 ms | 132080 KB |
#include<bits/stdc++.h> //#pragma GCC optimize("O3") //#pragma GCC target ("sse4") using namespace std; #define pb push_back #define all(x) (x).begin(),(x).end() #define MEM(x,a) memset((x),a,sizeof((x))) #define F first #define S second #define imx INT_MAX const long long MOD = (long long)(1e9+7); const long long MMX = (long long)(1e18); typedef long long LL; typedef pair<int,int> pii; typedef pair<LL,int>PQ; int n,x,ls=-1,fen[300004]; LL ans,a,rr,b; priority_queue<PQ,vector<PQ>,greater<PQ> >pq; queue<int>q; void up(int idx) { while(idx<=300004) { fen[idx]++; idx+=idx&(-idx); } return; } int ss(int idx) { LL re=0; while(idx>0) { re+=fen[idx]; idx-=idx&(-idx); } return re; } int main() { pq.push({1e18+1,-1}); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lld",&x); pq.push({x,i}); } while(pq.top().S!=-1) { if(pq.top().F!=ls) { while(!q.empty())up(q.front()),q.pop(),rr++; } ls=pq.top().F; q.push(pq.top().S); a=ss(pq.top().S); pq.pop(); ans+=(a*(rr-a)); } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Execution timed out | 2089 ms | 131896 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2071 ms | 132080 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2071 ms | 132080 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Execution timed out | 2089 ms | 131896 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |