Submission #167431

# Submission time Handle Problem Language Result Execution time Memory
167431 2019-12-08T14:40:32 Z PedroBigMan Nizin (COCI16_nizin) C++14
100 / 100
107 ms 10376 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF ((ll) pow(2,63) -1)
#define si signed
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll N; cin>>N;
    vector<ll> a; In(a,N);
    ll sum=0; REP(i,0,N) {sum+=a[i];}
    ll l=0; ll r=N;
    ll sl=a[0]; ll sr=0;
    ll ans=0;
    ll cov=0;
    ll curs=1;
    while(l<r)
    {
        if(sl<sr)
        {
            l++; sl+=a[l];
            curs++;
        }
        else if(sl>sr)
        {
            r--; sr+=a[r]; 
            curs++;
        }
        else
        {
            ans+=(curs-2);
            cov+=curs;
            l++; sl=a[l]; sr=0; 
            curs=1;
        }
    }
    cout<<ans+max(0LL,(N-cov-1))<<endl;
    return 0;
}

Compilation message

nizin.cpp: In function 'void Out(std::vector<long long int>)':
nizin.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
nizin.cpp:20:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
nizin.cpp:20:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1652 KB Output is correct
2 Correct 11 ms 1652 KB Output is correct
3 Correct 11 ms 1776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 5260 KB Output is correct
2 Correct 39 ms 5336 KB Output is correct
3 Correct 45 ms 5352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 10076 KB Output is correct
2 Correct 73 ms 9952 KB Output is correct
3 Correct 81 ms 9952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 10188 KB Output is correct
2 Correct 89 ms 10284 KB Output is correct
3 Correct 90 ms 10376 KB Output is correct