/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 516.0 KiB
#3 Wrong Answer 6ms 568.0 KiB
#4 Wrong Answer 11ms 792.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
   ll n  , s ,sum = 0, cur = 0 ; cin >> n >> s; ll a[n] ;
   for(int i = 0 ; i < n ; i++) cin >> a[i] , sum += a[i];
  ll X = sum / s ;
  if(X == 0) {
    cout << -1 << endl ;
    return ;
  }
  for(int i = 0 ; i < n ; i++) cur += (a[i] / X) ;
   if(cur == s) cout << X << "\n" ;
   else cout << -1 << "\n" ;


}
int main()
{
     __Heart__
    // READ("0in.txt") ;
    // WRITE("0out.txt") ;
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1057 Floor Sum
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-16 15:00:11
Judged At
2024-11-11 02:36:43
Judged By
Score
10
Total Time
11ms
Peak Memory
792.0 KiB