#include "secret.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <limits>
#include <map>
#include <utility>
#include <cctype>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <functional>
#include <iterator>
using namespace std;
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MAX_VALUE 1000000000
vector<int> v;
void Init(int N, int A[]) {
for(int i=0;i<N;i++) v.pb(A[i]);
}
int ss(int a,int b){
return min(a+2*(b/2),(int)MAX_VALUE);
}
int Query(int L, int R) {
int s=v[L];
for(int i=L+1;i<=R;i++) s=ss(s,v[i]);
return s;
}
#ifdef IOI
#include "secret.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 1000
#define MAX_Q 10000
#define MAX_VALUE 1000000000
static int N;
static int A[MAX_N];
static int Q;
static int L[MAX_Q];
static int R[MAX_Q];
static int secret_count;
int Secret(int X, int Y) {
++secret_count;
if (!(0 <= X && X <= MAX_VALUE)) {
fprintf(stderr, "Wrong Answer [1]\n");
exit(0);
}
if (!(0 <= Y && Y <= MAX_VALUE)) {
fprintf(stderr, "Wrong Answer [1]\n");
exit(0);
}
return (X + 2 * (Y / 2) < MAX_VALUE) ? (X + 2 * (Y / 2)) : MAX_VALUE;
}
int main() {
int i, j;
int secret_count_by_init;
int max_secret_count_by_query = 0;
if (1 != scanf("%d", &N)) {
fprintf(stderr, "error: cannot read N.\n");
exit(1);
}
if (!(1 <= N && N <= MAX_N)) {
fprintf(stderr, "error: N is out of bounds.\n");
exit(1);
}
for (i = 0; i < N; ++i) {
if (1 != scanf("%d", &A[i])) {
fprintf(stderr, "error: cannot read A[%d].\n", i);
exit(1);
}
if (!(0 <= A[i] && A[i] <= MAX_VALUE)) {
fprintf(stderr, "error: A[%d] is out of bounds.\n", i);
exit(1);
}
}
if (1 != scanf("%d", &Q)) {
fprintf(stderr, "error: cannot read Q.\n");
exit(1);
}
if (!(0 <= Q && Q <= MAX_Q)) {
fprintf(stderr, "error: Q is out of bounds.\n");
exit(1);
}
for (j = 0; j < Q; ++j) {
if (2 != scanf("%d%d", &L[j], &R[j])) {
fprintf(stderr, "error: cannot read L[%d] and R[%d].\n", j, j);
exit(1);
}
if (!(0 <= L[j] && L[j] <= R[j] && R[j] <= N - 1)) {
fprintf(stderr,
"error: L[%d] and R[%d] do not satisfy the constraints.\n",
j, j);
exit(1);
}
}
secret_count = 0;
Init(N, A);
secret_count_by_init = secret_count;
for (j = 0; j < Q; ++j) {
secret_count = 0;
printf("%d\n", Query(L[j], R[j]));
if (max_secret_count_by_query < secret_count) {
max_secret_count_by_query = secret_count;
}
}
fprintf(stderr, "number of calls to Secret by Init : %d\n",
secret_count_by_init);
fprintf(stderr, "maximum number of calls to Secret by Query : %d\n",
max_secret_count_by_query);
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
2732 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 1000000000. |
2 |
Incorrect |
91 ms |
2664 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 1000000000. |
3 |
Incorrect |
92 ms |
2640 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 1000000000. |
4 |
Incorrect |
340 ms |
4260 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 1000000000. |
5 |
Incorrect |
340 ms |
4260 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 1000000000. |
6 |
Incorrect |
341 ms |
4180 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 1000000000. |
7 |
Incorrect |
344 ms |
4348 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 1000000000. |
8 |
Incorrect |
344 ms |
4180 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 1000000000. |
9 |
Incorrect |
350 ms |
4548 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 1000000000. |
10 |
Incorrect |
348 ms |
4224 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 1000000000. |