답안 #339521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339521 2020-12-25T15:03:24 Z scales Bigger segments (IZhO19_segments) C++17
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
using namespace std;
int main()
{
      ios::sync_with_stdio(false);
      cin.tie(0);
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
     cin>>n;
     vector<long long> a(n);
     for(i=0;i<n;i++)
     {
         cin>>a[i];
     }
     kol=1;
     l=1;
     r=1;
     p=a[0];
     sum=0;
     while(r!=n)
     {
         //cout<<"l="<<l<<" r="<<r<<endl;
         while(sum<p && r!=n)
         {
             sum=sum+a[r];
             r++;
         }
         if(sum<p)
         {
             break;
         }
         else
         {
             kol++;
             while(sum-2*a[l]>=p)
             {
                 sum=sum-2*a[l];
                 l++;
             }
             p=sum;
             sum=0;
         }
     }
     cout<<kol<<endl;
    return 0;
}

Compilation message

segments.cpp: In function 'int main()':
segments.cpp:15:10: warning: unused variable 't' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |          ^
segments.cpp:15:14: warning: unused variable 'j' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |              ^
segments.cpp:15:16: warning: unused variable 'w' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                ^
segments.cpp:15:18: warning: unused variable 'dno' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                  ^~~
segments.cpp:15:22: warning: unused variable 'mini' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                      ^~~~
segments.cpp:15:31: warning: unused variable 'x' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                               ^
segments.cpp:15:33: warning: unused variable 'y' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                 ^
segments.cpp:15:35: warning: unused variable 'z' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                   ^
segments.cpp:15:37: warning: unused variable 'q' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                     ^
segments.cpp:15:39: warning: unused variable 'm' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                       ^
segments.cpp:15:45: warning: unused variable 'k' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                             ^
segments.cpp:15:47: warning: unused variable 'v' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                               ^
segments.cpp:15:55: warning: unused variable 'x1' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                       ^~
segments.cpp:15:58: warning: unused variable 'tip' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                          ^~~
segments.cpp:15:62: warning: unused variable 'g' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                              ^
segments.cpp:15:64: warning: unused variable 'maxi' [-Wunused-variable]
   15 |      int t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -