Submission #78725

# Submission time Handle Problem Language Result Execution time Memory
78725 2018-10-08T04:03:20 Z nxteru Bulldozer (JOI17_bulldozer) C++14
100 / 100
545 ms 66556 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct segtree{
  ll s[1<<12],ma[1<<12],mi[1<<12];
  void init(void){
      for(int i=0;i<1<<12;i++){
          s[i]=0;
          ma[i]=-INF;
          mi[i]=INF;
      }
  }
  void up(int a,ll x){
      a+=(1<<11)-1;
      ma[a]=x;
      mi[a]=x;
      while(a>0){
          a=(a-1)/2;
          ma[a]=max(ma[a*2+1],ma[a*2+2]);
          mi[a]=min(mi[a*2+1],mi[a*2+2]);
          s[a]=max(max(s[a*2+1],s[a*2+2]),ma[a*2+2]-mi[a*2+1]);
      }
  }
};
struct poi{
  ll x,y,a,b;
  bool operator<(const poi&q)const{
      if(y*q.x!=q.y*x)return y*q.x<q.y*x;
      if(a!=q.a)return a<q.a;
      return b<q.b;
  }
};
ll n,x[2005],y[2005],w[2005],s[2005],t[2005],ans;
segtree seg;
vector<PP>so;
vector<poi>q;
int main(void){
    seg.init();
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        ll nx,ny,nw;
        scanf("%lld%lld%lld",&nx,&ny,&nw);
        so.PB(PP(P(nx,-ny),nw));
    }
    sort(so.begin(),so.end());
    seg.up(0,0);
    for(int i=0;i<n;i++){
        x[i]=so[i].F.F;
        y[i]=-so[i].F.S;
        w[i]=so[i].S;
        s[i+1]+=s[i]+w[i];
        seg.up(i+1,s[i+1]);
        t[i]=i+1;
    }
    ans=seg.s[0];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(x[i]-x[j]>0){
                q.PB(poi{x[i]-x[j],-y[i]+y[j],min(i,j),max(i,j)});
            }
        }
    }
    sort(q.begin(),q.end());
    for(int i=0;i<q.size();i++){
        int a=q[i].a,b=q[i].b;
        s[t[a]]=s[t[a]]-w[a]+w[b];
        seg.up(t[a],s[t[a]]);
        swap(t[a],t[b]);
        if(i+1==q.size()||q[i].y*q[i+1].x!=q[i+1].y*q[i].x)ans=max(ans,seg.s[0]);
    }
    printf("%lld\n",ans);
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:73:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<q.size();i++){
                 ~^~~~~~~~~
bulldozer.cpp:78:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(i+1==q.size()||q[i].y*q[i+1].x!=q[i+1].y*q[i].x)ans=max(ans,seg.s[0]);
            ~~~^~~~~~~~~~
bulldozer.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
bulldozer.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&nx,&ny,&nw);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 868 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 792 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 896 KB Output is correct
26 Correct 4 ms 764 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 3 ms 896 KB Output is correct
29 Correct 3 ms 768 KB Output is correct
30 Correct 3 ms 768 KB Output is correct
31 Correct 3 ms 768 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 896 KB Output is correct
26 Correct 4 ms 764 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 3 ms 896 KB Output is correct
29 Correct 3 ms 768 KB Output is correct
30 Correct 3 ms 768 KB Output is correct
31 Correct 3 ms 768 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 527 ms 66292 KB Output is correct
34 Correct 507 ms 66312 KB Output is correct
35 Correct 515 ms 66420 KB Output is correct
36 Correct 498 ms 66308 KB Output is correct
37 Correct 519 ms 66400 KB Output is correct
38 Correct 510 ms 66328 KB Output is correct
39 Correct 502 ms 66328 KB Output is correct
40 Correct 506 ms 66328 KB Output is correct
41 Correct 515 ms 66328 KB Output is correct
42 Correct 499 ms 66328 KB Output is correct
43 Correct 515 ms 66412 KB Output is correct
44 Correct 515 ms 66328 KB Output is correct
45 Correct 503 ms 66344 KB Output is correct
46 Correct 509 ms 66328 KB Output is correct
47 Correct 499 ms 66332 KB Output is correct
48 Correct 517 ms 66344 KB Output is correct
49 Correct 509 ms 66324 KB Output is correct
50 Correct 502 ms 66348 KB Output is correct
51 Correct 506 ms 66348 KB Output is correct
52 Correct 525 ms 66300 KB Output is correct
53 Correct 507 ms 66400 KB Output is correct
54 Correct 512 ms 66328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 896 KB Output is correct
26 Correct 4 ms 764 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 3 ms 896 KB Output is correct
29 Correct 3 ms 768 KB Output is correct
30 Correct 3 ms 768 KB Output is correct
31 Correct 3 ms 768 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 527 ms 66292 KB Output is correct
34 Correct 507 ms 66312 KB Output is correct
35 Correct 515 ms 66420 KB Output is correct
36 Correct 498 ms 66308 KB Output is correct
37 Correct 519 ms 66400 KB Output is correct
38 Correct 510 ms 66328 KB Output is correct
39 Correct 502 ms 66328 KB Output is correct
40 Correct 506 ms 66328 KB Output is correct
41 Correct 515 ms 66328 KB Output is correct
42 Correct 499 ms 66328 KB Output is correct
43 Correct 515 ms 66412 KB Output is correct
44 Correct 515 ms 66328 KB Output is correct
45 Correct 503 ms 66344 KB Output is correct
46 Correct 509 ms 66328 KB Output is correct
47 Correct 499 ms 66332 KB Output is correct
48 Correct 517 ms 66344 KB Output is correct
49 Correct 509 ms 66324 KB Output is correct
50 Correct 502 ms 66348 KB Output is correct
51 Correct 506 ms 66348 KB Output is correct
52 Correct 525 ms 66300 KB Output is correct
53 Correct 507 ms 66400 KB Output is correct
54 Correct 512 ms 66328 KB Output is correct
55 Correct 511 ms 66328 KB Output is correct
56 Correct 523 ms 66308 KB Output is correct
57 Correct 542 ms 66308 KB Output is correct
58 Correct 513 ms 66344 KB Output is correct
59 Correct 535 ms 66356 KB Output is correct
60 Correct 529 ms 66344 KB Output is correct
61 Correct 536 ms 66384 KB Output is correct
62 Correct 528 ms 66344 KB Output is correct
63 Correct 530 ms 66372 KB Output is correct
64 Correct 530 ms 66388 KB Output is correct
65 Correct 498 ms 66328 KB Output is correct
66 Correct 537 ms 66328 KB Output is correct
67 Correct 503 ms 66328 KB Output is correct
68 Correct 503 ms 66332 KB Output is correct
69 Correct 504 ms 66328 KB Output is correct
70 Correct 517 ms 66412 KB Output is correct
71 Correct 494 ms 66400 KB Output is correct
72 Correct 509 ms 66324 KB Output is correct
73 Correct 499 ms 66328 KB Output is correct
74 Correct 511 ms 66300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 868 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 792 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 3 ms 768 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 3 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 3 ms 768 KB Output is correct
21 Correct 3 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 896 KB Output is correct
24 Correct 3 ms 896 KB Output is correct
25 Correct 3 ms 868 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 5 ms 768 KB Output is correct
37 Correct 3 ms 768 KB Output is correct
38 Correct 3 ms 768 KB Output is correct
39 Correct 3 ms 768 KB Output is correct
40 Correct 3 ms 896 KB Output is correct
41 Correct 4 ms 764 KB Output is correct
42 Correct 3 ms 768 KB Output is correct
43 Correct 3 ms 896 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 3 ms 768 KB Output is correct
46 Correct 3 ms 768 KB Output is correct
47 Correct 3 ms 768 KB Output is correct
48 Correct 527 ms 66292 KB Output is correct
49 Correct 507 ms 66312 KB Output is correct
50 Correct 515 ms 66420 KB Output is correct
51 Correct 498 ms 66308 KB Output is correct
52 Correct 519 ms 66400 KB Output is correct
53 Correct 510 ms 66328 KB Output is correct
54 Correct 502 ms 66328 KB Output is correct
55 Correct 506 ms 66328 KB Output is correct
56 Correct 515 ms 66328 KB Output is correct
57 Correct 499 ms 66328 KB Output is correct
58 Correct 515 ms 66412 KB Output is correct
59 Correct 515 ms 66328 KB Output is correct
60 Correct 503 ms 66344 KB Output is correct
61 Correct 509 ms 66328 KB Output is correct
62 Correct 499 ms 66332 KB Output is correct
63 Correct 517 ms 66344 KB Output is correct
64 Correct 509 ms 66324 KB Output is correct
65 Correct 502 ms 66348 KB Output is correct
66 Correct 506 ms 66348 KB Output is correct
67 Correct 525 ms 66300 KB Output is correct
68 Correct 507 ms 66400 KB Output is correct
69 Correct 512 ms 66328 KB Output is correct
70 Correct 511 ms 66328 KB Output is correct
71 Correct 523 ms 66308 KB Output is correct
72 Correct 542 ms 66308 KB Output is correct
73 Correct 513 ms 66344 KB Output is correct
74 Correct 535 ms 66356 KB Output is correct
75 Correct 529 ms 66344 KB Output is correct
76 Correct 536 ms 66384 KB Output is correct
77 Correct 528 ms 66344 KB Output is correct
78 Correct 530 ms 66372 KB Output is correct
79 Correct 530 ms 66388 KB Output is correct
80 Correct 498 ms 66328 KB Output is correct
81 Correct 537 ms 66328 KB Output is correct
82 Correct 503 ms 66328 KB Output is correct
83 Correct 503 ms 66332 KB Output is correct
84 Correct 504 ms 66328 KB Output is correct
85 Correct 517 ms 66412 KB Output is correct
86 Correct 494 ms 66400 KB Output is correct
87 Correct 509 ms 66324 KB Output is correct
88 Correct 499 ms 66328 KB Output is correct
89 Correct 511 ms 66300 KB Output is correct
90 Correct 525 ms 66328 KB Output is correct
91 Correct 516 ms 66320 KB Output is correct
92 Correct 517 ms 66352 KB Output is correct
93 Correct 515 ms 66428 KB Output is correct
94 Correct 513 ms 66400 KB Output is correct
95 Correct 497 ms 66336 KB Output is correct
96 Correct 513 ms 66324 KB Output is correct
97 Correct 514 ms 66332 KB Output is correct
98 Correct 509 ms 66400 KB Output is correct
99 Correct 509 ms 66312 KB Output is correct
100 Correct 223 ms 33464 KB Output is correct
101 Correct 224 ms 33484 KB Output is correct
102 Correct 229 ms 33596 KB Output is correct
103 Correct 232 ms 33596 KB Output is correct
104 Correct 267 ms 33484 KB Output is correct
105 Correct 332 ms 66300 KB Output is correct
106 Correct 332 ms 66432 KB Output is correct
107 Correct 326 ms 66356 KB Output is correct
108 Correct 326 ms 66488 KB Output is correct
109 Correct 335 ms 66328 KB Output is correct
110 Correct 506 ms 66556 KB Output is correct
111 Correct 500 ms 66328 KB Output is correct
112 Correct 499 ms 66456 KB Output is correct
113 Correct 497 ms 66296 KB Output is correct
114 Correct 524 ms 66300 KB Output is correct
115 Correct 505 ms 66324 KB Output is correct
116 Correct 505 ms 66404 KB Output is correct
117 Correct 502 ms 66300 KB Output is correct
118 Correct 500 ms 66456 KB Output is correct
119 Correct 499 ms 66332 KB Output is correct
120 Correct 2 ms 512 KB Output is correct
121 Correct 2 ms 512 KB Output is correct
122 Correct 516 ms 66412 KB Output is correct
123 Correct 504 ms 66392 KB Output is correct
124 Correct 531 ms 66244 KB Output is correct
125 Correct 518 ms 66456 KB Output is correct
126 Correct 545 ms 66328 KB Output is correct
127 Correct 531 ms 66348 KB Output is correct
128 Correct 509 ms 66328 KB Output is correct
129 Correct 523 ms 66332 KB Output is correct
130 Correct 510 ms 66440 KB Output is correct
131 Correct 507 ms 66328 KB Output is correct
132 Correct 519 ms 66360 KB Output is correct
133 Correct 516 ms 66456 KB Output is correct