QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#340472 | #4441. BIT Subway | Terac# | AC ✓ | 6ms | 6516kb | C++14 | 2.4kb | 2024-02-29 08:19:56 | 2024-02-29 08:19:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace IO {
#if ONLINE_JUDGE
#define getc() (IS == IT && (IT = (IS = ibuf) + fread(ibuf, 1, IL, stdin), IS == IT) ? EOF : *IS++)
#else
#define getc() getchar()
#endif
const int IL = 1 << 21, OL = 1 << 21;
int olen = 0;
char ibuf[IL], *IS = ibuf, *IT = ibuf, obuf[OL];
inline int read() {
register char ch = getc(); register int x = 0, f = 1;
while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
return x * f;
}
inline double readdb() {
register char ch = getc(); register double x = 0, f = 1;
while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
if(ch == '.') {
register double b = 0.1;
ch = getc();
while(isdigit(ch)) x += (ch - 48) * b, b *= 0.1, ch = getc();
}
return x * f;
}
inline int readstr(char *s) {
register char ch = getc(); register int len = 0;
while(!isalpha(ch)) ch = getc();
while(isalpha(ch)) s[++len] = ch, ch = getc();
return len;
}
inline void flush() { fwrite(obuf, 1, olen, stdout); olen = 0; }
inline void putc(register char ch) { obuf[olen++] = ch; }
template<class T>
inline void write(register T x) {
if(x < 0) obuf[olen++] = '-', x = -x;
if(x > 9) write(x / 10);
obuf[olen++] = x % 10 + 48;
}
} using namespace IO;
const int N = 1e5 + 10, mod = 1e9 + 7;
int n, a[N];
void MAIN() {
n = read();
for(int i = 1; i <= n; i++)
a[i] = read();
double res1 = 0, res2 = 0;
for(int i = 1; i <= n; i++) {
if(res2 >= 200) res2 += 0.5 * a[i];
else if(res2 >= 100) res2 += 0.8 * a[i];
else res2 += 1. * a[i];
if(res1 + a[i] < 100) { res1 += a[i]; continue; }
else if(res1 < 100 && res1 + a[i] >= 100) {
double t = 100. - res1;
double k = 0.8 * (a[i] - t);
double rr = a[i] - t;
res1 = 100.;
if(res1 + 0.8 * rr <= 200) {
res1 += 0.8 * rr;
continue;
}
t = 200 - res1;
k = 0.8 * rr;
res1 = 200. + (k - t) / 0.8 * 0.5;
}
else if(res1 >= 100 && res1 < 200) {
if(res1 + 0.8 * a[i] <= 200) { res1 += 0.8 * a[i]; continue; }
double t = 200 - res1;
double k = 0.8 * a[i];
res1 = 200. + (k - t) / 0.8 * 0.5;
}
else if(res1 >= 200) { res1 += 0.5 * a[i]; continue; }
}
printf("%.3lf %.3lf\n", res1, res2);
}
int main() {
int T = read();
while(T--) MAIN();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 6516kb
input:
10 10 20 50 105 200 11 31 88 177 30 122 12 75 200 65 200 200 1 2 3 4 5 6 10 10 95 5 125 200 10 20 70 60 55 7 10 99 126 70 10 32 22 200 199 20 77 10000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
504.500 564.500 473.000 523.000 411.000 411.000 515.000 540.000 5087.500 5087.500 1023956.500 1023962.900 1022476.500 1022481.000 5014830.000 5014855.000 5011888.500 5011908.000 5018160.500 5018176.300
result:
ok 10 lines