Submission #33889681
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double LD; #define rep(i,a,n) for (ll i=a;i<(ll)n;i++) #define per(i,a,n) for (ll i=n;i-->(ll)a;) #define pb push_back ll read(){ll r;scanf("%lld",&r);return r;} // read // nb + sum min(iA-B - E,0), i = 0~T-1; int main(){ ll N = read(); ll S = read(); ll T = read(); ll A = read(); ll B = read(); auto calc = [=](LD E){ ll l = 0; ll r = T-1; if(r*A-B-E<=0){ l = r; }else{ while(l+1<r){ ll m = (l+r)/2; if(m*A-B-E<=0) l = m; else r = m; } } return N * B+ A * l * (l+1) / 2 - (B+E) * (l+1) ; }; LD LE = 0; LD RE = A * T; while(calc(RE) > 0) RE *= 2; rep(t,0,10000){ // E增, 和减 LD E = (LE+RE)/2; (calc(E) > 0 ? LE : RE) = E; } LD ans = B + LE; if(S <= T) ans = min(ans,(LD)((T-S) * A)); printf("%.15Lf",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | G - Roll or Increment |
User | cromarmot |
Language | C++ (GCC 9.2.1) |
Score | 600 |
Code Size | 916 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 3816 KiB |
Compile Error
./Main.cpp: In function ‘ll read()’: ./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 10 | ll read(){ll r;scanf("%lld",&r);return r;} // read | ~~~~~^~~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, example0.txt, example1.txt, example2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 13 ms | 3576 KiB |
001.txt | AC | 3 ms | 3632 KiB |
002.txt | AC | 2 ms | 3684 KiB |
003.txt | AC | 2 ms | 3688 KiB |
004.txt | AC | 2 ms | 3660 KiB |
005.txt | AC | 2 ms | 3536 KiB |
006.txt | AC | 5 ms | 3628 KiB |
007.txt | AC | 2 ms | 3532 KiB |
008.txt | AC | 3 ms | 3732 KiB |
009.txt | AC | 5 ms | 3660 KiB |
010.txt | AC | 2 ms | 3732 KiB |
011.txt | AC | 2 ms | 3812 KiB |
012.txt | AC | 2 ms | 3696 KiB |
013.txt | AC | 2 ms | 3780 KiB |
014.txt | AC | 2 ms | 3560 KiB |
015.txt | AC | 2 ms | 3696 KiB |
016.txt | AC | 2 ms | 3536 KiB |
017.txt | AC | 2 ms | 3580 KiB |
018.txt | AC | 3 ms | 3688 KiB |
019.txt | AC | 7 ms | 3580 KiB |
020.txt | AC | 2 ms | 3732 KiB |
021.txt | AC | 2 ms | 3576 KiB |
022.txt | AC | 3 ms | 3816 KiB |
023.txt | AC | 3 ms | 3780 KiB |
024.txt | AC | 2 ms | 3784 KiB |
025.txt | AC | 4 ms | 3748 KiB |
026.txt | AC | 3 ms | 3660 KiB |
027.txt | AC | 3 ms | 3628 KiB |
028.txt | AC | 3 ms | 3696 KiB |
029.txt | AC | 6 ms | 3536 KiB |
030.txt | AC | 3 ms | 3628 KiB |
031.txt | AC | 5 ms | 3736 KiB |
032.txt | AC | 3 ms | 3692 KiB |
033.txt | AC | 4 ms | 3580 KiB |
034.txt | AC | 3 ms | 3696 KiB |
035.txt | AC | 3 ms | 3560 KiB |
036.txt | AC | 2 ms | 3532 KiB |
037.txt | AC | 2 ms | 3704 KiB |
038.txt | AC | 2 ms | 3736 KiB |
039.txt | AC | 2 ms | 3748 KiB |
040.txt | AC | 2 ms | 3576 KiB |
041.txt | AC | 2 ms | 3688 KiB |
042.txt | AC | 2 ms | 3700 KiB |
043.txt | AC | 2 ms | 3696 KiB |
044.txt | AC | 2 ms | 3780 KiB |
045.txt | AC | 2 ms | 3564 KiB |
example0.txt | AC | 2 ms | 3692 KiB |
example1.txt | AC | 3 ms | 3536 KiB |
example2.txt | AC | 2 ms | 3780 KiB |