Submission #1372830


Source Code Expand

#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what
 
using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;
 
int n;
int a[N], b[N];

int add(int x, int y) {
    x += y;
    if (x > n) x -= n;
    return x;
}
 
int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        b[i] = a[add(i, 1)] - a[i];
        sum += b[i];
    }
    for (int i = 1; i <= n; i++) {
        if ((b[i] % n + n) % n != (b[1] % n + n) % n) {
            cout << "NO";
            return 0;
        }
    }
    assert(0);
    cout << "YES";
    return 0;
    cout << "\n";
    for (int iter = 0; iter <= 1e5; iter++) {
        for (int i = 1; i <= n; i++) {
            b[i] = a[add(i, 1)] - a[i];
        }
        for (int j = 1; j <= n; j++) {
            b[j] -= iter;
        }
        ll ans = 0;
        for (int j = 1; j <= n; j++) {
            if (b[j] <= 0) {
                if (abs(b[j]) % n) {
                    ans = INF;
                    break;
                }
                ans += -b[j] / n;
            }
        }
        if (ans <= iter) {
            for (int j = 1; j <= n; j++) {
                cout << b[j] << " ";
            }
            cout << "\n";
            cout << iter << " " << ans << endl;
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

Submission Info

Submission Time
Task B - Boxes
User Nurlykhan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2184 Byte
Status RE
Exec Time 153 ms
Memory 1152 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 1
RE × 2
AC × 9
RE × 24
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt RE 142 ms 1024 KB
in10.txt RE 103 ms 384 KB
in11.txt RE 152 ms 1024 KB
in12.txt RE 151 ms 1024 KB
in13.txt RE 143 ms 896 KB
in14.txt RE 98 ms 256 KB
in15.txt RE 101 ms 256 KB
in16.txt RE 99 ms 256 KB
in17.txt RE 98 ms 256 KB
in18.txt RE 101 ms 256 KB
in19.txt AC 1 ms 256 KB
in2.txt RE 153 ms 1152 KB
in20.txt AC 1 ms 256 KB
in21.txt AC 55 ms 1024 KB
in22.txt AC 53 ms 1024 KB
in23.txt AC 54 ms 1024 KB
in24.txt RE 104 ms 256 KB
in25.txt RE 104 ms 384 KB
in26.txt RE 150 ms 1024 KB
in27.txt RE 151 ms 1024 KB
in3.txt RE 151 ms 1024 KB
in4.txt RE 151 ms 1024 KB
in5.txt RE 152 ms 1024 KB
in6.txt AC 54 ms 1024 KB
in7.txt AC 55 ms 1024 KB
in8.txt RE 103 ms 384 KB
in9.txt RE 104 ms 384 KB
sample1.txt RE 98 ms 256 KB
sample2.txt RE 99 ms 256 KB
sample3.txt AC 1 ms 256 KB