Submission #409531

# Submission time Handle Problem Language Result Execution time Memory
409531 2021-05-21T03:57:48 Z anime Fireworks (APIO16_fireworks) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%d %lld",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define umax(a,b) a = max(a,b);
#define umin(a,b) a = min(a,b);
#define endi puts("");
#define eps 1e-12
const int N = 1e6+12,INF=1e9+7;

main(){
    int n,m,i,j,ans=0,ans1=0,ans2=0,sum=0;
    cin>>n>>m;
    vector <int >v;
    for (i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        sum += y;
        v.pb(y);
    }
    sum /= m;
    for (int x:v){
        ans += abs(x-sum);
        ans1 += abs(x-(sum+1));
        ans2 += abs(x-(sum-1));
    }
    cout <<min(ans,min(ans1,ans2));

}



















Compilation message

fireworks.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
fireworks.cpp: In function 'int main()':
fireworks.cpp:28:15: warning: unused variable 'j' [-Wunused-variable]
   28 |     int n,m,i,j,ans=0,ans1=0,ans2=0,sum=0;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -