Submission #48132

# Submission time Handle Problem Language Result Execution time Memory
48132 2018-05-10T07:24:16 Z gs15120 역사적 조사 (JOI14_historical) C++14
15 / 100
284 ms 10200 KB
#include <bits/stdc++.h>
using namespace std;

struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
              return x<a.x;
    }
};

vector<int> v;
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
long long l[685130];

int o[335555];
int j[15];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z[33333];

P u[141111];
stack<int> s;

//set<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
//list<int> l;
//string r;
//char r[1152][1111];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x/d!=b.x/d) return a.x<b.x;
    return a.y<b.y;
}

void f(int e,int m)
{
    l[i+o[m]-1]+=v[o[m]]*e;
    for(int h=(i+o[m]-1)/2;h>0;l[h]=max(l[h*2],l[h*2+1]),h>>=1);
}

int main()
{
    v.push_back(0);
    scanf("%d %d",&a,&b);
    d=sqrt(b);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        if(!p[o[t]]) p[o[t]]=1,v.push_back(o[t]);
    }
    sort(v.begin(),v.end());
    for(int t=1;t<v.size();p[v[t]]=t,t++);
    for(int t=1;t<=a;o[t]=p[o[t]],t++);
    for(i=1;i<v.size();i<<=1);
    n=1;
    for(int t=1;t<=b;u[t].z=t,t++)
        scanf("%d %d",&u[t].x,&u[t].y);
    sort(u+1,u+1+b,as);
    for(int t=1;t<=b;t++)
    {

        for(;m<u[t].y;f(1,++m));
        for(;n>u[t].x;f(1,--n));
        for(;m>u[t].y;f(-1,m--));
        for(;n<u[t].x;f(-1,n++));
        z[u[t].z]=l[1];
    }
    for(int t=1;t<=b;t++)
        printf("%lld\n",z[t]);
}

Compilation message

historic.cpp: In function 'int main()':
historic.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int t=1;t<v.size();p[v[t]]=t,t++);
                 ~^~~~~~~~~
historic.cpp:65:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=1;i<v.size();i<<=1);
             ~^~~~~~~~~
historic.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&a,&b);
     ~~~~~^~~~~~~~~~~~~~~
historic.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&o[t]);
         ~~~~~^~~~~~~~~~~~
historic.cpp:68:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&u[t].x,&u[t].y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 2 ms 772 KB Output is correct
5 Correct 2 ms 772 KB Output is correct
6 Correct 2 ms 772 KB Output is correct
7 Correct 2 ms 908 KB Output is correct
8 Correct 2 ms 908 KB Output is correct
9 Correct 2 ms 908 KB Output is correct
10 Correct 2 ms 908 KB Output is correct
11 Correct 2 ms 908 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 1016 KB Output is correct
15 Correct 2 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1052 KB Output is correct
2 Correct 3 ms 1076 KB Output is correct
3 Correct 3 ms 1100 KB Output is correct
4 Correct 5 ms 1132 KB Output is correct
5 Correct 10 ms 1300 KB Output is correct
6 Correct 17 ms 1340 KB Output is correct
7 Correct 16 ms 1412 KB Output is correct
8 Correct 14 ms 1480 KB Output is correct
9 Correct 13 ms 1560 KB Output is correct
10 Correct 21 ms 1872 KB Output is correct
11 Correct 21 ms 1872 KB Output is correct
12 Correct 23 ms 1912 KB Output is correct
13 Correct 22 ms 2004 KB Output is correct
14 Correct 21 ms 2100 KB Output is correct
15 Correct 20 ms 2204 KB Output is correct
16 Correct 16 ms 2292 KB Output is correct
17 Correct 10 ms 2388 KB Output is correct
18 Correct 19 ms 2484 KB Output is correct
19 Correct 22 ms 2712 KB Output is correct
20 Correct 25 ms 2804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2804 KB Output is correct
2 Correct 2 ms 2804 KB Output is correct
3 Correct 2 ms 2804 KB Output is correct
4 Correct 2 ms 2804 KB Output is correct
5 Correct 3 ms 2804 KB Output is correct
6 Correct 3 ms 2804 KB Output is correct
7 Correct 5 ms 2848 KB Output is correct
8 Correct 9 ms 3164 KB Output is correct
9 Correct 21 ms 3672 KB Output is correct
10 Correct 10 ms 3672 KB Output is correct
11 Runtime error 70 ms 8196 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 8196 KB Output is correct
2 Correct 122 ms 8196 KB Output is correct
3 Correct 284 ms 9204 KB Output is correct
4 Runtime error 52 ms 10200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -