답안 #1029808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029808 2024-07-21T10:55:03 Z vjudge1 Addk (eJOI21_addk) C++17
0 / 100
2000 ms 860 KB
#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
// #define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 50000 + 101;
const int md = 998244353;
const int MOD = 1e8;
const int mega = 1e6 + 3;
const int inf = 1e9;

ll gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}
void solve() {
    int n , k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 1; i <= n; ++i)cin >> a[i];
    int m;
    cin >> m;
    while(m--){
        int ty;
        cin >> ty;
        if(ty == 2){
            int l , r , m;
            cin >> l >> r >> m;
            int sum = 0 , x = 0 , cnt = 0;
            while(l + m - 1<= r){
                x = 0;
                for(int i = l; i <= l + m - 1; ++i)x += a[i];
                sum += x;
                l++;
            }
            cout << sum << nl;
        }
        else{
            int nega;
            cin >> nega;
        }
    }
}

signed main() {
    SPEED;
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    #ifndef ONLINE_JUDGE
    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:45:35: warning: unused variable 'cnt' [-Wunused-variable]
   45 |             int sum = 0 , x = 0 , cnt = 0;
      |                                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 40 ms 472 KB Output is correct
3 Incorrect 274 ms 616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2059 ms 720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -