Task: | Pörssihai |
Sender: | zxc |
Submission time: | 2015-01-29 15:36:03 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 17 |
#3 | ACCEPTED | 71 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.07 s | 1 | details |
#2 | ACCEPTED | 0.07 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.06 s | 2 | details |
#5 | ACCEPTED | 0.05 s | 2 | details |
#6 | ACCEPTED | 0.06 s | 2 | details |
#7 | ACCEPTED | 1.34 s | 3 | details |
#8 | ACCEPTED | 1.62 s | 3 | details |
#9 | ACCEPTED | 1.61 s | 3 | details |
#10 | ACCEPTED | 1.38 s | 3 | details |
#11 | ACCEPTED | 1.58 s | 3 | details |
#12 | ACCEPTED | 1.38 s | 3 | details |
#13 | ACCEPTED | 1.88 s | 3 | details |
#14 | ACCEPTED | 2.05 s | 3 | details |
#15 | ACCEPTED | 1.56 s | 3 | details |
#16 | ACCEPTED | 1.49 s | 3 | details |
#17 | ACCEPTED | 1.50 s | 3 | details |
#18 | ACCEPTED | 1.37 s | 3 | details |
#19 | ACCEPTED | 1.76 s | 3 | details |
#20 | ACCEPTED | 1.62 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:17:9: warning: unused variable 'q' [-Wunused-variable] int q; ^
Code
#include <iostream> #include <vector> using namespace std; const int MN = 1e6+100; int t[MN]; struct LOL { double F,S; int Q; }; vector<LOL > v; double y; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int q; //cin>>q; y = 0; v.push_back({(double)-1, double(0), -1}); //v.push_back({0, (double)y, 0}); for(int i = 0; i < n; ++i) { int qq; cin>>qq; y -= qq; while(v.size() > 1) { auto q = v[v.size()-2]; auto w = v.back(); // cout<<q.F<<' '<<q.S<<" * "<<w.F<<' '<<w.S<<'\n'; if((y-q.S)/(i-q.F) > (y-w.S)/(i-w.F)) break; // cout<<"POIS\n"; // cout<<"POIS "<<v.back().Q<<'\n'; v.pop_back(); } //cout<<"i "<<i<<'\n'; //for(auto y: v) { // cout<<y.Q<<' '; // } //cout<<'\n'; int lo = 0; int hi = v.size()-1; int best = 0; while(lo < hi) { int mid = (lo+hi)/2; if((y-v[mid].S)/(i-v[mid].F) > (y-v[mid+1].S)/(i-v[mid+1].F)) { lo = mid+1; best = mid+1; } else { hi = mid-1; best = mid-1; } } cout<<i-v[best].Q<<' '; v.push_back({(double)i, y, i}); } cout<<'\n'; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
200 5986 845897 759781 171305 7836... |
correct output |
---|
1 1 2 3 4 1 1 2 4 1 2 1 2 5 6 ... |
user output |
---|
1 1 2 3 4 1 1 2 4 1 2 1 2 5 6 ... |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
200 607815 909742 130099 813674 34... |
correct output |
---|
1 1 3 1 5 1 1 3 4 5 1 1 1 4 10... |
user output |
---|
1 1 3 1 5 1 1 3 4 5 1 1 1 4 10... |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
200 921591 381013 930275 151815 69... |
correct output |
---|
1 2 1 4 5 1 2 3 4 1 2 7 1 2 3 ... |
user output |
---|
1 2 1 4 5 1 2 3 4 1 2 7 1 2 3 ... |
Test 4
Group: 2
Verdict: ACCEPTED
input |
---|
5000 952303 272950 268680 897180 13... |
correct output |
---|
1 2 3 1 2 1 4 8 9 10 1 2 13 14... |
user output |
---|
1 2 3 1 2 1 4 8 9 10 1 2 13 14... |
Test 5
Group: 2
Verdict: ACCEPTED
input |
---|
5000 815856 460818 496023 308974 33... |
correct output |
---|
1 2 3 4 5 1 1 2 9 1 11 12 13 1... |
user output |
---|
1 2 3 4 5 1 1 2 9 1 11 12 13 1... |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
5000 4889 373080 366119 72135 10214... |
correct output |
---|
1 1 2 3 4 1 1 2 3 4 5 1 2 3 1 ... |
user output |
---|
1 1 2 3 4 1 1 2 3 4 5 1 2 3 1 ... |
Test 7
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 444890 370930 385763 316218 44... |
correct output |
---|
1 2 3 4 1 2 3 4 9 1 2 1 4 5 6 ... |
user output |
---|
1 2 3 4 1 2 3 4 9 1 2 1 4 5 6 ... |
Test 8
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 202077 270536 246808 189471 19... |
correct output |
---|
1 1 2 3 4 1 1 3 4 5 1 2 8 9 10... |
user output |
---|
1 1 2 3 4 1 1 3 4 5 1 2 8 9 10... |
Test 9
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 736301 784710 628727 708231 64... |
correct output |
---|
1 1 3 4 5 6 7 1 2 1 4 1 1 7 1 ... |
user output |
---|
1 1 3 4 5 6 7 1 2 1 4 1 1 7 1 ... |
Test 10
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 242104 238293 242641 242281 24... |
correct output |
---|
1 2 1 2 3 1 2 3 1 2 1 4 11 12 ... |
user output |
---|
1 2 1 2 3 1 2 3 1 2 1 4 11 12 ... |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 252952 189698 245317 275463 24... |
correct output |
---|
1 2 1 1 2 4 7 1 2 3 1 2 3 1 1 ... |
user output |
---|
1 2 1 1 2 4 7 1 2 3 1 2 3 1 1 ... |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 214451 357457 213436 351167 21... |
correct output |
---|
1 1 2 1 4 5 6 7 8 9 1 1 3 4 5 ... |
user output |
---|
1 1 2 1 4 5 6 7 8 9 1 1 3 4 5 ... |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 363703 361248 358992 356404 35... |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 718920 716974 715476 714540 71... |
correct output |
---|
1 2 3 4 5 6 7 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 2 3 4 5 6 7 1 1 1 1 1 1 1 1 ... |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 614078 647174 701983 580935 58... |
correct output |
---|
1 1 1 3 4 1 6 8 9 1 1 3 4 14 1... |
user output |
---|
1 1 1 3 4 1 6 8 9 1 1 3 4 14 1... |
Test 16
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 788376 788632 788880 789118 78... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 17
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 711774 711541 711305 711627 71... |
correct output |
---|
1 2 3 1 2 6 1 2 1 2 3 6 7 1 2 ... |
user output |
---|
1 2 3 1 2 6 1 2 1 2 3 6 7 1 2 ... |
Test 18
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 685798 944128 587123 653271 65... |
correct output |
---|
1 1 2 3 4 1 2 7 8 10 11 1 1 3 ... |
user output |
---|
1 1 2 3 4 1 2 7 8 10 11 1 1 3 ... |
Test 19
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 734074 734109 733868 733873 73... |
correct output |
---|
1 1 3 4 5 1 1 1 1 1 1 1 3 5 6 ... |
user output |
---|
1 1 3 4 5 1 1 1 1 1 1 1 3 5 6 ... |
Test 20
Group: 3
Verdict: ACCEPTED
input |
---|
1000000 143117 1 267468 262833 141471 ... |
correct output |
---|
1 2 1 2 3 1 1 2 4 1 2 10 11 12... |
user output |
---|
1 2 1 2 3 1 1 2 4 1 2 10 11 12... |