답안 #164807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164807 2019-11-23T14:07:30 Z mosiashvililuka Money (IZhO17_money) C++14
0 / 100
1500 ms 47480 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,pas,f[1000009],read2[1000009],read[1000009],p[1000009],pi,mi=1000003,dp[1000009],fen[1000009];
vector <int> v[2000009];
vector <int>::iterator it;
void upd(int q, int w){
    while(q<=1000000){
        fen[q]+=w;
        q=q+(q&(-q));
    }
}
int readd(int q){
    if(q<=0) return 0;
    int jm=0;
    while(q>0){
        jm+=fen[q];
        q=q-(q&(-q));
    }
    return jm;
}
int main(){
    scanf("%d",&a);
    for(b=1; b<=a; b++){
        scanf("%d",&p[b]);
    }
    for(b=1; b<=a; b++){
        if(p[b]==p[b-1]) continue;
        pi++;
        f[pi]=p[b];
        upd(p[b],1);
        read[b]=readd(p[b]);
        read2[b]=readd(p[b]-1);
    }
    a=pi;
    dp[0]=1;
    for(b=1; b<=a; b++){
        if(f[b]>=f[b-1]) dp[b]=dp[b-1]; else dp[b]=b;
    }
//    for(b=1; b<=1000000; b++) read[b]+=read[b-1];
/*    for(b=1; b<=a; b++) cout<<read[b]<<" ";
    return 0;*/
    for(b=1; b<=a; b++){
        v[read[b]-b+mi].push_back(b);
    }
    b=a;
    while(b>0){
        //cout<<b<<endl;
        pas++;
        it=lower_bound(v[read2[b]-b+1+mi].begin(),v[read2[b]-b+1+mi].end(),dp[b]);
/*        if(it==v[read2[b]-b+1+mi].end()||(*it)>=b){
            b=b-1;
            continue;
        }*/
        b=(*it)-1;
    }
    cout<<pas;
    return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&a);
     ~~~~~^~~~~~~~~
money.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&p[b]);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47352 KB Output is correct
2 Correct 51 ms 47412 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 49 ms 47352 KB Output is correct
5 Correct 48 ms 47352 KB Output is correct
6 Correct 50 ms 47480 KB Output is correct
7 Execution timed out 1558 ms 47352 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47352 KB Output is correct
2 Correct 51 ms 47412 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 49 ms 47352 KB Output is correct
5 Correct 48 ms 47352 KB Output is correct
6 Correct 50 ms 47480 KB Output is correct
7 Execution timed out 1558 ms 47352 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47352 KB Output is correct
2 Correct 51 ms 47412 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 49 ms 47352 KB Output is correct
5 Correct 48 ms 47352 KB Output is correct
6 Correct 50 ms 47480 KB Output is correct
7 Execution timed out 1558 ms 47352 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 47352 KB Output is correct
2 Correct 51 ms 47412 KB Output is correct
3 Correct 50 ms 47352 KB Output is correct
4 Correct 49 ms 47352 KB Output is correct
5 Correct 48 ms 47352 KB Output is correct
6 Correct 50 ms 47480 KB Output is correct
7 Execution timed out 1558 ms 47352 KB Time limit exceeded
8 Halted 0 ms 0 KB -