Submission #51757

# Submission time Handle Problem Language Result Execution time Memory
51757 2018-06-21T03:29:10 Z model_code None (JOI14_ho_t3) C++17
100 / 100
166 ms 2304 KB
// O(N logN) solution
#include <cstdio>

int main()
{
  int n;
  scanf("%d",&n);
  static int A[1000000];
  long long AA=0;
  for(int i=0;i<n;i++){
    scanf("%d",A+i);
    AA+=A[i];
  }
  long long l=0,r=AA+1;
  while(l+1<r){
    long long m=(l+r)/2;
    static long long S[1000000];
    static int P[1000000];
    for(int i=0;i<n;i++){
      if(i>0){
	P[i]=P[i-1]-1;
	S[i]=S[i-1]-A[i-1];
      }
      else{
	P[i]=0;
	S[i]=0;
      }
      while(S[i]<m){
	S[i]+=A[(i+P[i])%n];
	P[i]++;
      }
    }
    bool B=0;
    for(int i=0;i<n;i++){
      if(AA-S[i]-S[(i+P[i])%n]>=m){
	B=1;
      }
    }
    if(B){
      l=m;
    }
    else{
      r=m;
    }
  }
  printf("%lld\n",l);
  return 0;
}

Compilation message

2014_ho_t3.cpp: In function 'int main()':
2014_ho_t3.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
2014_ho_t3.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",A+i);
     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 3 ms 636 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 636 KB Output is correct
16 Correct 2 ms 636 KB Output is correct
17 Correct 2 ms 636 KB Output is correct
18 Correct 2 ms 636 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 3 ms 636 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 636 KB Output is correct
16 Correct 2 ms 636 KB Output is correct
17 Correct 2 ms 636 KB Output is correct
18 Correct 2 ms 636 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
21 Correct 8 ms 636 KB Output is correct
22 Correct 8 ms 636 KB Output is correct
23 Correct 8 ms 636 KB Output is correct
24 Correct 9 ms 636 KB Output is correct
25 Correct 8 ms 636 KB Output is correct
26 Correct 13 ms 636 KB Output is correct
27 Correct 12 ms 636 KB Output is correct
28 Correct 13 ms 636 KB Output is correct
29 Correct 12 ms 636 KB Output is correct
30 Correct 12 ms 636 KB Output is correct
31 Correct 6 ms 636 KB Output is correct
32 Correct 5 ms 636 KB Output is correct
33 Correct 6 ms 636 KB Output is correct
34 Correct 6 ms 636 KB Output is correct
35 Correct 6 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 3 ms 636 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 636 KB Output is correct
16 Correct 2 ms 636 KB Output is correct
17 Correct 2 ms 636 KB Output is correct
18 Correct 2 ms 636 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
21 Correct 8 ms 636 KB Output is correct
22 Correct 8 ms 636 KB Output is correct
23 Correct 8 ms 636 KB Output is correct
24 Correct 9 ms 636 KB Output is correct
25 Correct 8 ms 636 KB Output is correct
26 Correct 13 ms 636 KB Output is correct
27 Correct 12 ms 636 KB Output is correct
28 Correct 13 ms 636 KB Output is correct
29 Correct 12 ms 636 KB Output is correct
30 Correct 12 ms 636 KB Output is correct
31 Correct 6 ms 636 KB Output is correct
32 Correct 5 ms 636 KB Output is correct
33 Correct 6 ms 636 KB Output is correct
34 Correct 6 ms 636 KB Output is correct
35 Correct 6 ms 636 KB Output is correct
36 Correct 146 ms 2304 KB Output is correct
37 Correct 151 ms 2304 KB Output is correct
38 Correct 151 ms 2304 KB Output is correct
39 Correct 166 ms 2304 KB Output is correct
40 Correct 155 ms 2304 KB Output is correct
41 Correct 143 ms 2304 KB Output is correct
42 Correct 142 ms 2304 KB Output is correct
43 Correct 144 ms 2304 KB Output is correct
44 Correct 139 ms 2304 KB Output is correct
45 Correct 159 ms 2304 KB Output is correct
46 Correct 66 ms 2304 KB Output is correct
47 Correct 50 ms 2304 KB Output is correct
48 Correct 71 ms 2304 KB Output is correct